i had always assumed that
case wrapped:
promotes to
case wrapped?:
if the switch parameter is optional.
so i was surprised that the following causes a compiler error:
func test1(bool:Bool?)
{
switch bool
{
case nil, true:
break
case false:
break
}
}
switch.swift:3:5: error: switch must be exhaustive
switch bool
^
switch.swift:3:5: note: add missing case: '.some(_)'
switch bool
instead it must be written as:
func test2(bool:Bool?)
{
switch bool
{
case nil, true?:
break
case false?:
break
}
}
why?