from inside a foreach? isn’t that returning from t...
# announcements
s
from inside a foreach? isn’t that returning from the lambda you’re passing to foreach
k
No, that would be
return@forEach
.
return
by default will return to the outermost scope
s
ah, true
so in the
.forEach { return 0 }
example, is
return
legal because it’s used to return from the outer function early?
k
well in this context, the
forEach
is the outermost scope
exactly the same happens with
run
,
let
, etc etc
k
it isn't, the function is the outermost scope. His example does not hit
error
, it returns early with the value of
0
k
i'm fooling around with it and there is some weird behaviour indeed
a