0Pricing
Swift Academy · Lesson

for-in Loops with Ranges

Iterating with for-in using integer ranges and closed/half-open range operators.

Welcome

Loops let you repeat work without repeating code. The `for-in` loop is Swift's most versatile iteration tool, working with ranges, collections, and any sequence.

Closed Range: a...b

The closed range operator `...` includes both endpoints: ```swift for i in 1...5 { print(i) // 1, 2, 3, 4, 5 } ``` This is the most common range used with `for-in`.

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