[swift-evolution] Proposal: Do not allow redundant unwrapping.

Joe Groff jgroff at apple.com
Wed Dec 9 11:13:44 CST 2015


> On Dec 9, 2015, at 6:31 AM, Amir Michail via swift-evolution <swift-evolution at swift.org> wrote:
> 
> The following should result in a compile error:
> 
> var x:Int? = 5
> var y:Int?
> 
> y = x! // compiler error, unwrapping is redundant
> 
> The unnecessary unwrapping gives the wrong impression about the type of y — namely that it is Int.

The compiler doesn't know this. You gave x type 'Int?', not 'Int'.

-Joe

> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution



More information about the swift-evolution mailing list