0

Can someone tell me which way I go wrong here?

let streetlight = ("green", "red") switch streetlight { case let ("red", "yellow") where "red" == "yellow": print("(\("red"), \("yellow")) still missing the green") case let ("green", "red") where "green" == "red": print("(\("green"), \("red")) still missing yellow") case let ("green", "yellow") where "green" == "yellow": print("(\("green"), \("yellow")) still missing red") default: print("you need to check Google") } thank you

13th May 2020, 1:13 AM
Regine Margareta
Regine Margareta - avatar
2 ответов
+ 2
Remove quotes from around variable names and maybe give them less confusing names that don't conflict with the values of the tuple. let streetlight = ("green", "red") switch streetlight { case let (a, b) where a == "yellow": print("(\(a), \(b)) still missing the green") case let (a, b) where a == "red": print("(\(a), \(b)) still missing yellow") case let (a, b) where a == "yellow": print("(\(a), \(b)) still missing red") default: print("you need to check Google") }
13th May 2020, 4:33 AM
ChaoticDawg
ChaoticDawg - avatar
0
thank you so much. I was just thinking of that yesterday 🙏🏽
13th May 2020, 10:40 AM
Regine Margareta
Regine Margareta - avatar