Reimplementation of Implicitly Unwrapped Optionals
The new mental model for IOUs is one where you consider
!
to be a synonym for?
with the addition that it adds a flag on the declaration letting the compiler know that the declared value can be implicitly unwrapped.[…]
There are three places where using
!
as part of a type is permitted:
- Property declarations
- Parameters in function declarations
- Return values in function declarations
[…]
Because implicitly unwrapped optionals are no longer a type distinct from optionals, they can’t be inferred as a type or as any part of a type.
[…]
Note that the result of
AnyObject
lookup is treated as an optional that is implicitly unwrapped. If you lookup a property that itself is also declared as implicitly unwrapped, the expression now has two levels of implicit unwrapping[…]if let
andguard let
only unwrap a single level of optionality.