Kotlin has a notion of function inlining with the return statement being inlined too. This means you can do, e.g.:
list.forEach {
if (it == something) return;
}
and you aren't returning from the code block, but the enclosing function. Yet behind the scenes forEach is being expanded by the compiler into a regular imperative for loop, in a macro-like way.
list.forEach { if (it == something) return; }
and you aren't returning from the code block, but the enclosing function. Yet behind the scenes forEach is being expanded by the compiler into a regular imperative for loop, in a macro-like way.