I am positive that the following swift code has covered all possibilities, but Xcode keeps telling me that, "Switch must be exhaustive, consider adding a default clause."
Can anyone tell me what did I miss? Thanks.
let a = false
let b = false
let c = false
func test(a: Bool, _ b: Bool, _ c: Bool) {
switch (a, b, c) {
case (true, false, _):
print("Moved left!!!")
case (true, true, _):
print("Moved right!!!")
case (false, _, false):
print("Moved up!!!")
case (false, _, true):
print("Moved down!!!")
// Error: Switch must be exhaustive, consider adding a default clause.
}
}
test(false, false, false)
test(false, false, true)
test(false, true, false)
test(false, true, true)
test(true, false, false)
test(true, false, true)
test(true, true, false)
test(true, true, true)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…