What does this print?
let point = (x: 4, y: 0)
switch point {
case (0, 0):
print("Origin")
case (_, 0):
print("X-axis")
case (0, _):
print("Y-axis")
default:
print("Other")
}
Try it in the online Swift Playground →
[spoiler title="Solution"]
Answer:
X-axis
Explanation:
Pattern matching uses wildcards to match tuples where y is 0.
[/spoiler]