In Kotlin, I cannot do a break or continue within a function loop and my lambda -- like I can from a normal for loop. For example, th
break
continue
for
forEach with break can be specificly substituted with any function:
forEach
(1..20).any { x -> (x == 5).apply { // break on true if (!this) { results2.add(x) } } }
Or possibly even shorter:
(1..20).any { x -> results2.add(x) x == 4 // break on true }