0Pricing
Swift Academy · Lesson

break, continue and Labeled Statements

Controlling loop flow with break, continue and labeled loops in Swift.

Welcome

`break` and `continue` give you fine-grained control over loop execution. Labeled statements extend this power to nested loops. Let's learn when each is appropriate.

break — Exit the Loop Early

`break` immediately terminates the current loop: ```swift for i in 1...10 { if i == 5 { break } print(i) } // 1, 2, 3, 4 ``` Execution continues with the first statement after the loop.

All lessons in this course

  1. for-in Loops with Ranges
  2. while and repeat-while Loops
  3. Iterating Collections with for-in
  4. break, continue and Labeled Statements
← Back to Swift Academy