<div dir="ltr">This same operator (except spelled as ??=) was up as a proposal and rejected in February. See <a href="http://thread.gmane.org/gmane.comp.lang.swift.evolution/7694">http://thread.gmane.org/gmane.comp.lang.swift.evolution/7694</a>.</div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, May 12, 2016 at 10:41 AM, Rod Brown via swift-evolution <span dir="ltr">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I’m tentatively supportive of this proposal. I definitely see the use case (assign only if not not nil).  Interested to hear the opinions of others here :)<br>
<br>
-Rod<br>
<br>
<br>
&gt; On 12 May 2016, at 11:59 PM, Jose Manuel Sánchez Peñarroja via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br>
&gt;<br>
&gt; Sorry if this has already been discussed, if so I couldn’t find it.<br>
&gt;<br>
&gt; I would like to propose to add to Swift an optional assignment operator ?=<br>
&gt; I think this would nicely align with the other uses of ?, and avoid repetition in this case:<br>
&gt;<br>
&gt;       var value = 5<br>
&gt;<br>
&gt;       var possibleNewValue: Int? = nil<br>
&gt;<br>
&gt;       value = possibleNewValue ?? value<br>
&gt;<br>
&gt; It would be used like this:<br>
&gt;<br>
&gt;       value ?= possibleNewValue<br>
&gt;<br>
&gt; I’ve found quite a few cases in which this would be very useful to me. It is already possible to implement it, but having it defined in the standard library would define an standard, and prevent different semantics depending on who implements it.<br>
&gt;<br>
&gt;<br>
&gt;       infix operator ?= {<br>
&gt;         associativity right<br>
&gt;          precedence 90<br>
&gt;          assignment<br>
&gt;       }<br>
&gt;<br>
&gt;       func ?= &lt;T&gt;(inout lhs: T, rhs: T?) {<br>
&gt;           lhs = rhs ?? lhs<br>
&gt;       }<br>
&gt;<br>
&gt;<br>
&gt; Regards,<br>
&gt; José Manuel Sanchez<br>
&gt; _______________________________________________<br>
&gt; swift-evolution mailing list<br>
&gt; <a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
&gt; <a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
<br>
_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">Trent Nadeau</div>
</div>