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

Using switch

We saw in Chapter2, Basic Swift that a Swift switch statement will test for the equality of any type, not just Int, and that we can test for values within a range.

That's just the start. The switch statement is an extremely flexible mechanism, and is capable of reducing large amount of if else code to much more concise, readable, and elegant blocks of code.