Increased Safety in Swift 3
Things are different with Swift 3.0. The
!ininit!indicates that the initialization process can fail, and if it doesn’t, that the resulting instance may be forced (i.e., implicitly unwrapped). Unlike in Swift 2.x, instances resulting frominit!areOptionals and notImplicitlyUnwrappedOptionals. That means you will have to employ optional binding or chaining to access the underlying value.[…]
We never explicitly declared that
nilPersonshould be anImplicitlyUnwrappedOptional. And it’s not great that the compiler inferred unsafe type information.Swift 3.0 solves this problem by treating
ImplicitlyUnwrappedOptionals asOptionalunless we explicitly declare that we want anImplicitlyUnwrappedOptional.