[swift-evolution] [Pitch] Introducing the "Unwrap or Die" operator to the standard library
jordan_rose at apple.com
Wed Jun 28 16:46:55 CDT 2017
> On Jun 28, 2017, at 14:40, Erica Sadun via swift-evolution <swift-evolution at swift.org> wrote:
> The `!!` operator should follow the same semantics as `Optional.unsafelyUnwrapped`, which establishes a precedent for this approach:
> > "The unsafelyUnwrapped property provides the same value as the forced unwrap operator (postfix !). However, in optimized builds (-O), no check is performed to ensure that the current instance actually has a value. Accessing this property in the case of a nil value is a serious programming error and could lead to undefined behavior or a runtime error."
Note that 'unsafelyUnwrapped' does not perform the check in optimized builds (like 'assert'), while '!' does (like 'precondition'). If we go with '!!', it should behave like 'precondition', not 'assert'.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution