How to use switch case where statement in Swift

1 Answer

0 votes
let point = (2, -2)

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




/*
run:

(2, -2) x == -y

*/

 



answered Feb 11, 2021 by avibootz

Related questions

...