[swift-evolution] Proposal: Add "none" and simplify the language.

Amir Michail a.michail at me.com
Thu Jan 7 11:46:53 CST 2016


Examples:

var x:Int = none // uninitialized but not an optional

print(x) // run-time error as x is uninitialized

if x == nil { … } // compile time error… x can never be nil because it is not an optional

if x == none { x = 2 } // … but it can be uninitialized

Optionals can also be uninitialized:

var y:Int? = none // uninitialized and an optional

if y == nil { … } // run-time error as y is uninitialized

y = nil

if y == nil { … } // fine



More information about the swift-evolution mailing list