<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=""><div class="">Yeah, as previously discussed you’d usually be better doing something like:</div><div class=""><br class=""></div><div class=""><font face="Monaco" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>struct Foo {</font></div><div class=""><font face="Monaco" class=""><span class="Apple-tab-span" style="white-space:pre">                </span>var value:Int?</font></div><div class=""><font face="Monaco" class=""><br class=""></font></div><div class=""><font face="Monaco" class=""><span class="Apple-tab-span" style="white-space:pre">                </span>func someMethod() {</font></div><div class=""><font face="Monaco" class=""><span class="Apple-tab-span" style="white-space:pre">                        </span>let value = self.value ?? 0 // This is no longer optional</font></div><div class=""><font face="Monaco" class=""><span class="Apple-tab-span" style="white-space:pre">                        </span>…</font></div><div class=""><font face="Monaco" class=""><span class="Apple-tab-span" style="white-space:pre">                </span>}</font></div><div class=""><font face="Monaco" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>}</font></div><div class=""><br class=""></div><div class="">Since you end up with a non-optional version to work with, which this operator wouldn’t do (requiring you to unwrap it to use it anyway). To make the operator be as useful it would have to implicitly shadow the variable that it’s being assigned to, which would be strange and require some syntax of its own to be clear; in effect the ?? operator already has all the information you need as shown above, it’s a little longer but it’s more self-documenting so I think it covers the use-cases of an optional assignment pretty well.</div><br class=""><div><blockquote type="cite" class=""><div class="">On 12 May 2016, at 23:12, Chris Lattner via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><br class=""><blockquote type="cite" class="">On May 12, 2016, at 2:38 PM, Tod Cunningham via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""><br class="">I ended up creating a ??= operator about a month ago to do something very similar. &nbsp;It’s a shame it won’t be made part of the official library. &nbsp;Although, it is very easy to add.<br class=""><br class=""><br class="">Just like the ?? operator the default value is only evaluated if the optional in nil. &nbsp;However, unlike ?? it will<br class=""><br class="">change the optional to be equal to the value on the right, iff the optional was nil.<br class=""></blockquote><br class="">We formally discussed &amp; rejected this already:<br class=""><a href="http://article.gmane.org/gmane.comp.lang.swift.evolution/7694" class="">http://article.gmane.org/gmane.comp.lang.swift.evolution/7694</a><br class=""><br class="">-Chris<br class="">_______________________________________________<br class="">swift-evolution mailing list<br class="">swift-evolution@swift.org<br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></body></html>