<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Feb 27, 2016, at 10:02 AM, Ross O'Brien <<a href="mailto:narrativium+swift@gmail.com" class="">narrativium+swift@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">This is less desirable than ??= would have been. To summarise the two operators:<div class=""><br class=""></div><div class="">lhs ??= rhs. lhs is an Optional<T>, rhs is a T or Optional<T>.</div><div class="">If lhs is nil, assign to lhs the value of rhs. If lhs is not nil, do nothing.</div><div class=""><br class=""></div><div class="">lhs := rhs. lhs is an Optional<T>, rhs is a T or Optional<T>.</div><div class="">If lhs is nil, assign to lhs the value of rhs. If lhs is not nil, crash with an assertion error.</div><div class=""><br class=""></div><div class="">The ??= operator is safer; its behaviour is clear and it doesn't cause my code to crash. := is more dangerous; if I want to be sure my app won't crash, I now need to check whether lhs is nil first... and if I do that, I might as well use the = operator.</div><div class=""><br class=""></div><div class="">I don't see what advantages your operator brings to Swift, or why you think it should be accepted when ??= operator was rejected.</div></div></div></blockquote><div><br class=""></div><div>This is how I write code. I use preconditions everywhere because I want to know about errors as soon as possible.</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Sat, Feb 27, 2016 at 2:47 PM, Amir Michail <span dir="ltr" class=""><<a href="mailto:a.michail@me.com" target="_blank" class="">a.michail@me.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><br class=""><div class=""><span class=""><blockquote type="cite" class=""><div class="">On Feb 27, 2016, at 9:46 AM, Ross O'Brien <<a href="mailto:narrativium+swift@gmail.com" target="_blank" class="">narrativium+swift@gmail.com</a>> wrote:</div><br class=""><div class=""><div dir="ltr" class="">How is this different from the rejected ??= proposal?</div><div class="gmail_extra"><br class=""></div></div></blockquote><div class=""><br class=""></div></span><div class="">If the value is not nil, the program stops with an assertion error.</div><span class=""><div class=""><br class=""></div><blockquote type="cite" class=""><div class=""><div class="gmail_extra"><div class="gmail_quote">On Sat, Feb 27, 2016 at 2:34 PM, Amir Michail via swift-evolution <span dir="ltr" class=""><<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Consider the use of “!” in the following:<br class="">
<br class="">
var x: Int? = 5<br class="">
<br class="">
x! = 2 // “!” is used to ensure non-nil value before assignment<br class="">
<br class="">
The idea is to have a similar method for ensuring a nil value.<br class="">
<br class="">
So instead of writing:<br class="">
<br class="">
precondition( x == nil )<br class="">
x = 3<br class="">
<br class="">
You could write:<br class="">
<br class="">
x := 3<br class="">
<br class="">
_______________________________________________<br class="">
swift-evolution mailing list<br class="">
<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a><br class="">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="">
</blockquote></div><br class=""></div>
</div></blockquote></span></div><br class=""></div></blockquote></div><br class=""></div>
</div></blockquote></div><br class=""></body></html>