There are three so-called _structural jump operators_ that are sort of like *goto* but much nicer: *return*, *break* and *continue*. By default, their behavior is as follows:
* *return* returns from the _nearest enclosing_ _[function|Functions]_, and not a [function literal|Function literals]
* *break* terminates the _nearest enclosing_ _[loop|Control structures#Loops]_
* *continue* either proceeds to the next step of the _nearest enclosing_ _[loop|Control structures#Loops]_ or to the next branch in the _nearest enclosing_ _[*when* expression|Control structures#When]_

h3. Break and continue at labels

Any expression in [Kotlin] may be marked with a _label_. Labels have the from of the {{@}} sign followed by an optional identifier, for examples {{@}}, {{@abc}}, {{@fooBar}} are valid labels (see the [grammar|Grammar#label]). To label an expression, we just put a label in front of it:
{jet}
@loop for (i in 1..100) {
  // ...
}
{jet}

Now, we can qualify a *break* or *continue* with a label:
{jet}
@loop for (i in 1..100) {
  for (j in 1..100) {
    if (...)
      break@loop
  }
}
{jet}
A *break* qualified with a label jumps to the execution point right after the loop marked with that label. A *continue* proceeds to the next iteration of that loop.

h3. Return at labels

With [function literals|Function literals], [local functions|Functions#Local functions] and [object expression|Object expressions and Declarations], functions can be nested in [Kotlin]. _Qualified_ *{_}return{_}{*}_'s_ allow us to return from an _outer function_. The most important use case is returning from a function literal. Recall that when we write this:
{jet}
fun foo() {
  ints.forEach {
    if (it == 0) return
    print(it)
  }
}
{jet}
The *return* expression returns from the nearest enclosing _function_, i.e. {{foo}}. If we need to return from a _function literal_, we have to label it and qualify the *return*:
{jet}
fun foo() {
  ints.forEach @lit {
    if (it == 0) return@lit
    print(it)
  }
}
{jet}
Now, it returns only from the function literal. Often times it is more convenient to use the shortest implicit label {{@}} for function literals:
{jet}
fun foo() {
  ints.forEach {
    if (it == 0) return@ // Works if there's one and only one function literal in lexical scope up to named entity (function or class)
    print(it)
  }
}
{jet}
Note that such non-local returns are supported only for function literals passed to inline-functions.

When returning a value, the parser gives preference to the qualified return, i.e.
{jet}
return@a 1
{jet}
means "return 1 at label @a" and not "return a labeled expression (@a 1)".

Named functions automatically define labels:
{jet}
fun outer() {
  fun inner() {
    return@outer // the label @outer was defined automatically
  }
}
{jet}

{note:title=Non-local returns are not implemented yet}See the corresponding [issue|http://youtrack.jetbrains.com/issue/KT-1435].{note}

{anchor:custom}
h4. Break and continue in custom control structures

[Inline functions|Functions#Inline functions] make writing performant "custom control structures" easy, for example, the {{forEach()}} function that executes a function literal for every element in a collection:
{jet}
inline fun <T> Collection<T>.forEach(body : (item : T) -> Unit) {
  for (item in this) {
    body(item)
  }
}
{jet}
Note that this function is not exactly a redundant example easily substitutable by a normal *for* loop. Consider the following code:
{jet}
ints filter {it > 0} sortby {-it} forEach {print(it)}
{jet}

Now, what happens when we write *break* (or *continue*) inside the body of {{forEach}}? We simply get a compile-time error, because, lexically, there's no loop to *break*:
{jet}
ints forEach {
  if (it < 0) <error desc="'break' is only allowed inside a loop">break</error> // Error: 'break' does not belong to a loop
  print(it)
}
{jet}
But, actually, there _is_ a loop, hidden inside {{forEach}}, and it is _inlined_ there, so we should be able to tell the compiler to understand that. An we can, by annotating the loop inside {{forEach}} with the {{loop}} annotation. The function parameter should also be annotated with {{loopbody}} annotation:
{jet}
<class desc="jet softkeyword":>inline fun <T> Collection<T>.forEach(<class desc="jet softkeyword":>loopbody body : (item : T) -> Unit) {
  [<class desc="jet softkeyword":>loop] for (item in this) {
    body(item)
  }
}
{jet}
Now, the compiler allows *break* and *continue* in the function literal argument passed to {{forEach}}, and these operators apply to the loop marked with {{@@}}.

{note:title=Break and continue for custom control structures are not implemented yet}See the corresponding [issue|http://youtrack.jetbrains.com/issue/KT-1436].{note}

h3. Qualified {{this}} expressions

See [*This* expressions|This expressions#Qualified].

h3. What's next

* [Ranges]
* [This expressions]
* [Tuples]
* [Type casts]