var number = 10
var bool = false
switch (number, bool) {
case (_, false):
print("bool is false")
case (10, _):
print("number is 10")
default:
print("whatever")
}
The above would print "bool is false"
var number = 10
var bool = false
switch (number, bool) {
case (10, _):
print("number is 10")
case (_, false):
print("bool is false")
default:
print("whatever")
}
The above would print "number is 10"
To further test this I moved the default
case to the top and got:
error: additional 'case' blocks cannot appear after the 'default' block of a 'switch'
Questions:
So is this standard Foundation behavior? I looked at the library but didn't find anything about the sequence of cases.
Additionally does this mean two cases can't be identical but can be overlapping...and it would just fall through whichever case happened first?