[swift-evolution] [Pitch] Introducing the "Unwrap or Die" operator to the standard library

Jordan Rose 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'.

Jordan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170628/7dea510f/attachment.html>


More information about the swift-evolution mailing list