Advanced Pattern Matching

Pattern Types

released Fri, 15 Feb 2019
Swift Version 5.0

Pattern Types

So now we've seen several patterns in action. But what's the syntax here? Which other things can we match for? Swift distinguishes 7 different patterns. We're going to have a quick look at each of them.

All of those patterns can not only be used with the switch keyword, but also with the if, guard, and for keywords. For details on this, read on.