Mastering macOS Programming
上QQ阅读APP看书,第一时间看更新

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")
}