[swift-evolution] [Review] SE-0054: Abolish ImplicitlyUnwrappedOptional type
Brent Royal-Gordon
brent at architechies.com
Fri Mar 25 18:16:46 CDT 2016
> I do have a question.
>
> let x: Int! = 5
> let y = x
>
> let a = x ?? 1 // would this still work?
> Or would it auto unwrapping always? meaning when .some `a = 5` or crash when .none?
> I am assuming that x is `Int?` that autounwraps. Just curious if autounwraps only happen on assignment like in `y = x`
I believe that, in this example, `y` is of type `Int?`, that is, a non-autounwrapped optional. An autounwrapped optional is only unwrapped if Swift cannot make the code type-check without unwrapping it.
--
Brent Royal-Gordon
Architechies
More information about the swift-evolution
mailing list