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

Ross O'Brien narrativium+swift at gmail.com
Sat Feb 27 08:46:00 CST 2016


How is this different from the rejected ??= proposal?

On Sat, Feb 27, 2016 at 2:34 PM, Amir Michail via swift-evolution <
swift-evolution at swift.org> wrote:

> 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
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160227/cd849efe/attachment.html>


More information about the swift-evolution mailing list