[swift-evolution] Proposal: An assignment operator := that ensures nil before assignment.

Amir Michail a.michail at me.com
Sat Feb 27 08:34:35 CST 2016

Consider the use of “!” in the following:

var x: Int? = 5

x! = 2 // “!” is used to ensure non-nil value before assignment

The idea is to have a similar method for ensuring a nil value.

So instead of writing:

precondition( x == nil )
x = 3

You could write:

x := 3

More information about the swift-evolution mailing list