I have a switch statement in Swift like this:
switch tuple {
case (let someObject, let current, nil):
return true
// Other cases...
}
The tuple is of type (SomeObject?, SomeObject, SomeObject?)
, and what I'm saying in English is: Match the case where the first two elements are not nil, while the third (an Optional) is nil.
Xcode 7 is telling me that since I didn't use the bindings someObject
and current
, I should replace it with an underscore. But if I replaced the first element in the tuple with an underscore, wouldn't it also match the cases where the first element is nil, because _
means the compiler ignores the value? I have a separate case for situations where the first element is nil.
For the record, it looks like my code still works as I expect it to, but I want to be sure and I can't find any documentation on this anywhere.