> ## Documentation Index
> Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Kotlin Labeled Continue

A labeled `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.

```kotlin theme={"dark"}
labelName@ for (item in collection) {
    for (innerItem in innerCollection) {
        if (condition) {
            continue@labelName
        }
    }
}
```

## 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`, or `do-while`).
* **Invocation:** The invocation syntax (`continue@labelName`) must not contain whitespace between the `continue` keyword, the `@` symbol, and the identifier.
* **Control Transfer:** When the labeled `continue` is 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 `for` loop, execution jumps to the next step of the targeted loop's iterator.
  * In `while` and `do-while` loops, execution jumps directly to the boolean condition evaluation of the targeted loop.

## Structural Example

The following demonstrates the execution path when a labeled `continue` is invoked:

```kotlin theme={"dark"}
outer@ for (i in 1..3) {
    for (j in 1..3) {
        if (i == 2 && j == 2) {
            // Terminates the j loop for the current i iteration.
            // Control transfers to the iterator of the 'outer@' loop (i = 3).
            continue@outer 
        }
        println("i=$i, j=$j")
    }
}
```

**Execution Output:**

```text theme={"dark"}
i=1, j=1
i=1, j=2
i=1, j=3
i=2, j=1
i=3, j=1
i=3, j=2
i=3, j=3
```

In this structure, when `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`.

<div
  style={{ 
display: "flex", 
justifyContent: "space-between", 
alignItems: "center", 
maxWidth: "754px", 
padding: "1rem 0",
marginBottom: "24px"
}}
>
  <span style={{ fontWeight: "bold", fontSize: "1.25rem", color: "var(--tw-prose-headings)", fontFamily: "Inter, ui-sans-serif, system-ui, sans-serif" }}>Tired of Poor Kotlin Skills? Fix That With Deep Grasping!</span>

  <a
    href="https://syntblaze.com"
    target="_blank"
    style={{ 
  marginLeft: "24px",
  textDecoration: "none", 
  backgroundColor: "#007AFF",
  color: "#ffffff", 
  padding: "6px 16px", 
  borderRadius: "16px",
  fontSize: "0.9rem",
  fontWeight: "600",
  textAlign: "center",
  transition: "background-color 0.2s ease"
}}
  >
    Learn More
  </a>
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/skill-tracking.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=b9b0305c93bb501c9e767b5c76c88835" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/skill-tracking.png" />

  <img src="https://mintcdn.com/syntblazellc/23tyuOzaWS88qFlc/images/nuggets.png?fit=max&auto=format&n=23tyuOzaWS88qFlc&q=85&s=c86c80197299762989e9b882419b2109" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/nuggets.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/bite-sized-exercises.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=a65f9a38c37ff28ab73ed783c53c60e3" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/bite-sized-exercises.png" />
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap", marginTop: "12px" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/mastery-chain.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=748a1763454713e679260fbb95f154a2" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/mastery-chain.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-previews.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=242f61448ff5dd6deaaab2dccc13b507" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-previews.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-explanations.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=cf0fc1c31f9cd0fc26716781be05fbc9" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-explanations.png" />
</div>
