- Mastering macOS Programming
- Stuart Grimshaw
- 58字
- 2021-07-02 22:54:30
Compound cases
Cases can be combined on one line, if they are required to share the same block of code:
let a = 1
switch a
{
case 1,3,5,7,9:
print("a is a single digit positive odd number")
case 0, 2,4,6,8:
print("a is a single digit positive even number")
default:
print("a is not a single digit positive number")
}