- Mastering macOS Programming
- Stuart Grimshaw
- 54字
- 2021-07-02 22:54:30
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")
}