Tsallaka zuwa abun ciki
Justice Tech School

Swift Ranges

1...3 includes 3 and 1..<3 stops before it. stride gives custom steps. Ranges work in loops and switch cases.

Example
for i in 1...3 { print(i, terminator: " ") }
print()
for i in stride(from: 0, to: 10, by: 3) { print(i, terminator: " ") }
print()
print((1..<4).contains(4))

Exercise

Stop before the end.

14

Quiz Test

Does 1..<4 include 4?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.