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

Erica Sadun erica at ericasadun.com
Wed Jun 28 17:00:45 CDT 2017


> On Jun 28, 2017, at 3:46 PM, Jordan Rose <jordan_rose at apple.com> wrote:
> 
> 
> 
>> On Jun 28, 2017, at 14:40, Erica Sadun via swift-evolution <swift-evolution at swift.org <mailto: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

Noted and will incorporate into updated text

Thanks, -- E

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


More information about the swift-evolution mailing list