> On 26 Sep 2016, at 00:26, William Sumner via swift-evolution 
> <[email protected]> wrote:
> 
>> 
>>  let roomCount = john.residence.numberOfRooms
>> 
>>  // error: value of optional type 'Residence?' not unwrapped; did
>> you mean to use '!' or '?'?
>> 
>> As general rule of thumb, whenever I get an error and the system tells
>> me what I probably meant, that is a pretty good sign the system isn't
>> doing all it can for me and making me jump through an unnecessary
>> hoop.

In this case, the compiler hasn’t told you what you probably mean. It’s given 
you two different meanings to choose from and hasn’t actually excluded other 
ways to fix the issue e.g. if let or guard let or even an extension to Optional.

As Haravikk and Brent have said, assuming either of these as the default is 
dangerous.

Assuming ! as the default, to my mind negates the point of introducing 
optionals at all, we might as well go back to null references. The whole point 
is to eliminate the “no value” problem at compile time, not run time.

Assuming ? as the default is more insidious. The application may carry on and 
may persist state that is incorrect.

I think the current behaviour is correct.

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

Reply via email to