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

Using the where keyword

We use the where keyword to add additional tests within the case statement:

switch a 
{
case 0..<10 where a%2 == 0:
print("a is a single digit positive even number")
case 0..<10:
print("a is a single digit positive odd number")
default:
print("a is not a single digit positive number")
}