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

Alan Westbrook alan at rockwoodsoftware.com
Wed Jun 28 19:54:25 CDT 2017

> On Jun 28, 2017, at 5:43 PM, Alan Westbrook via swift-evolution <swift-evolution at swift.org> wrote:
>> On Jun 28, 2017, at 5:27 PM, Xiaodi Wu via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>> In the initial example, repeated here in largely identical form, the desired comment is "array must be non-empty." In what way does that provide more information than a bare `!`?
> I’m going to second this sentiment with the feeling that the message is seemingly redundant. It feels akin to the comment in this line of code:
>     let value = 1 // This value is set to 1
> On an error, one gets the trap with the optional unwrapped message, and goes to the code where they see what is being forced by assumption.
> Does the message spelling out the code in natural language help?

Perhaps I am misunderstanding, we should probably not focus on the content of the message, but rather that it exists at all.

Assuming that the fatal-error-with-message is useful, is it important to have a shorthand for this pattern built into the language?

If we think so, I believe the original proposal is the best solution so far, given the arguments against using ?? fatal…


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

More information about the swift-evolution mailing list