Swift Switch
switch must cover every case and there is no implicit fallthrough. Cases can match ranges, tuples and conditions with where.
Example
let day = 3
switch day {
case 1: print("Mon")
case 2, 3: print("Tue or Wed")
case 4...7: print("Late week")
default: print("Other")
}Exercise
Fallback case.
switch x { : break }
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.