diesieben07
05/04/2018, 2:12 PMspand
05/04/2018, 2:20 PMdiesieben07
05/04/2018, 2:21 PMval x: (Int) -> Int = {
// cannot return here
}rook
05/04/2018, 2:21 PMrook
05/04/2018, 2:21 PMreturn from lambdas
int foo = 4
foo.let{
if(it != 4) {
return@let
}
else {
Timber.d("foo")
}
}
is perfectly functioning codediesieben07
05/04/2018, 2:21 PMlet, that is a normal function. You are not returning from the lambda.spand
05/04/2018, 2:22 PMrook
05/04/2018, 2:22 PMdiesieben07
05/04/2018, 2:23 PMhho
05/04/2018, 2:26 PMreturn won't work when you assign the lambda to a variable...rook
05/04/2018, 2:27 PMdiesieben07
05/04/2018, 2:28 PMval x: (Int) -> Int = lit@{
return@lit 13
}diesieben07
05/04/2018, 2:29 PMreturn@let thing shown above does not "return from the lambda", it returns early from let (which is an inline function).hho
05/04/2018, 2:31 PMforeach with a lambda stored in a val.diesieben07
05/04/2018, 2:32 PMforEach.hho
05/04/2018, 2:43 PMhho
05/04/2018, 2:43 PMdiesieben07
05/04/2018, 2:43 PM