How to use switch statement that match multiple values in one case with Swift

1 Answer

0 votes
let ch: Character = "b"
 
switch ch {
case "a", "c", "d", "e":
    print("a, c, d, e")
case "b", "w", "x", "y", "f", "g":
    print("b, w, x, y, f, g")

default:
    print("default")
}
 
 
 
 
 
 
/*
run:
 
b, w, x, y, f, g
 
*/

 



answered Feb 11, 2021 by avibootz

Related questions

1 answer 199 views
1 answer 152 views
1 answer 147 views
...