Returns and Jumps
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:
val s = person.name ?: return
The type of these expressions is the Nothing type.
Break and Continue Labels
Any expression in Kotlin may be marked with a label. Labels have the form of an identifier followed by the @
sign, for exam