joshua-r2
10/13/2017 - 7:33 PM

Return from a Lambda

How to exit a Lambda and NOT exit the parent function. Using return in a lambda will typically exit out of the function in which the lambda is called.


fun lookForRightDoggo(doges: List<Doggo>){

  /*
  Notice the gitout@ label
  Syntax:
  anchor = label@
  trigger = @label
  */
  doges.forEach gitout@{
    //If triggered, will leave the lambda, no lookForRightDoggo
    if(it.name = "Brutus" && it.type = "Shibe") @gitout
  }


}