⇒ Returns and jumps
- Kotlin has three structural jump expressions:
- return by default returns from the nearest enclosing function or anonymous function.
- break terminates the nearest enclosing loop.
- continue proceeds to the next step of the nearest enclosing loop.
- → All of these expressions can be used as part of larger expressions:
⇒ labels
- Any expression in Kotlin may be marked with a label.
- Labels have the form of an identifier followed by the @ sign
- such as abc@ or fooBar@. To label an expression , just add a label in front of it.
loop@ for (i in 1..100) {
for (j in 1..100) {
if (...) break@loop
}
}
loop@ is label and it is being used in break statement to break outer loop from inner loop