why does this work:
func foo<T, U>(_ bar1:T?, _ bar2:U?)
{
switch (bar1, bar2)
{
case (let a?, let b?):
print(a, b)
case (let a?, nil):
print(a, -1)
case(nil, let b?):
print(-1, b)
case (nil, nil):
print("")
}
}
foo(Optional<Int>(1), Optional<(Int, Int)>((5, 6)))
but not this?
switch (Optional<Int>(1), Optional<(Int, Int)>((5, 6)))
{
case (let a?, let b?):
print(a, b)
case (let a?, nil):
print(a, -1)
case(nil, let b?):
print(-1, b)
case (nil, nil):
print("")
}
error: switch must be exhaustive
switch (Optional<Int>(1), Optional<(Int, Int)>((5, 6)))
^
note: add missing case: '(_, .some(_, _))'
switch (Optional<Int>(1), Optional<(Int, Int)>((5, 6)))