A labeledDocumentation Index
Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
Use this file to discover all available pages before exploring further.
continue is a control flow expression in Kotlin that terminates the current iteration of a specifically targeted enclosing loop and immediately proceeds to its next iteration. By binding a continue statement to a custom label, execution bypasses the default behavior of targeting the innermost loop, allowing precise control over nested iteration structures.
Syntax
A label is defined by an identifier followed immediately by the@ symbol, placed directly before the loop declaration. The jump is executed using the continue keyword appended with the @ symbol and the target identifier.
Mechanics and Execution Flow
- Label Declaration: Any valid Kotlin identifier can be used as a label (e.g.,
outer@,loopA@). It must prefix a loop construct (for,while, ordo-while). - Invocation: The invocation syntax (
continue@labelName) must not contain whitespace between thecontinuekeyword, the@symbol, and the identifier. - Control Transfer: When the labeled
continueis evaluated, the Kotlin compiler discards all remaining statements in the current iteration of both the innermost loop and any intermediate loops up to the targeted labeled loop. - Loop Evaluation:
- In a
forloop, execution jumps to the next step of the targeted loop’s iterator. - In
whileanddo-whileloops, execution jumps directly to the boolean condition evaluation of the targeted loop.
- In a
Structural Example
The following demonstrates the execution path when a labeledcontinue is invoked:
i == 2 and j == 2, the continue@outer expression prevents i=2, j=2 and i=2, j=3 from executing. The inner loop is aborted, and the outer loop immediately advances to i = 3.
Master Kotlin with Deep Grasping Methodology!Learn More





