How to use switch statement that match x, y point in one case with Swift

1 Answer

0 votes
let point = (3, 0)

switch point {
case (let x, 0):
    print("x-axis / x = \(x)")
case (0, let y):
    print("y-axis / y = \(y)")
case let (x, y):
    print("else x, y = (\(x), \(y))")
}




/*
run:

x-axis / x = 3

*/

 



answered Feb 11, 2021 by avibootz
...