On Jun 28, 2017, at 6:43 PM, Alan Westbrook via swift-evolution 
<[email protected]> wrote:
> 
> 
>> On Jun 28, 2017, at 5:27 PM, Xiaodi Wu via swift-evolution 
>> <[email protected] <mailto:[email protected]>> 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?
> 
> Alan

I have replied to another email but will repeat the point here: The proposed 
`!!` operator differs from the direct use of `!` in that it explains a fact 
known to hold true, allowing the lhs to safely unwrap. 

The alternatives are:

* forced unwrap -- comments do not transfer to runtime, which leads coders to 
use:
* using guard with fatalError -- the !! operator provides an elegant sugared 
shortcut for this common code

-- E


_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to