Hello. I discovered that if we are switching optional enumeration we have case .none.
enum Temperature {
case cold, warm
}
func checkTemp(temperature: Temperature?) {
switch temperature {
case .cold: break
case .warm: break
case .none: break
}
}
Please give me the link to proposal of that feature.
when you have a static member Foo.bar that returns Foo and you're in a context that expect instance of Foo you can just write .bar (for example let x: Int = .zero )
if you have value of type Foo you can use it in places that expect Foo? without explicitly writing .some (for example let x: Int? = 123 )
What you're doing is switching on two enumerations, one nested inside another. We can write it more explicitly to make it more clear where none is coming from
func checkTemp(temperature: Optional<Temperature>) {
switch temperature {
case Optional.some(Temperature.cold): break
case Optional.some(Temperature.warm): break
case Optional.none: break
}
}