Swift 6 · Basics and optionals

Loops and switch

switch must be exhaustive and supports patterns and ranges.

for number in 1...3 { print(number) }

switch score {
case 0..<50: print("low")
case 50...: print("high")
default: break
}

Official Swift 6 documentation

More basics and optionals commands

All basics and optionals commands · Swift 6 cheatsheet

Was this page helpful?