This is an artificial problem because I want to learn more about swift. The fast compiler complains that the following is not exhaustive. Of course, in the general case, he cannot determine whether the allegations of the case are exhaustive. What is the best way I should tell the compiler that my list is exhaustive, for example, in the following case?
let point = (2, 2)
switch point {
case let (x, y) where x == y:
println("on the x=y line")
case let (x, y) where x != y:
println("somewhere else off x=y line")
}
The only option to add an empty default value: cases?
source
share