Switch - RaduG/swift_learning GitHub Wiki
Basic format
switch value {
case val1:
// statements
case val2, val3:
// statements
...
default:
// statements
}
All switch statements must be exhaustive. Either have a default clause or ensure that the cases cover the entire value space.
The fallthrough statement
To fall through the next case in the switch statement (similar to C when a case doesn't have a break statement)
switch value {
case 1:
print("Val1")
fallthrough
default:
print("And now we're default")
}
/*
If value == 1, this will print:
Val1
And now we're default
*/