<div dir="ltr">If it has a value already the nit wouldn&#39;t call anything as it technically hasn&#39;t been set. Only if it already has a value does it try and set something in which case the didSet is called :)</div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Dec 15, 2015 at 11:16 PM, Jacob Bandes-Storch 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"><div dir="ltr">One possible caveat is with custom setters.<div><br></div><div>If &quot;a&quot; already has a value, does &quot;a ??= b&quot; call the custom setter/willSet/didSet, or does it see the nil and short-circuit?</div><div><br></div><div>This can be implemented today:</div><div><br></div><div>    func ??=(inout lhs: T?, @autoclosure rhs: () -&gt; T?) { if lhs == nil { lhs = rhs() } }</div><div><br></div><div>However, the use of &quot;inout&quot; will always cause the didSets to be triggered at the call site, when just using if-statements instead wouldn&#39;t have done so.</div><div class="gmail_extra"><br clear="all"><div><div><div dir="ltr"><div>Jacob<br></div></div></div></div>
<br><div class="gmail_quote"><div><div class="h5">On Tue, Dec 15, 2015 at 3:10 PM, Brent Royal-Gordon 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></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><span>&gt; I think that the existing syntax for “??” handles this need fairly well without requiring an additional assignment operator:<br>
&gt;<br>
&gt;       a = a ?? []<br>
<br>
</span>When the variable is `a`, sure. When it’s `scoreboardViewController.selectedScoreboard`, not so much.<br>
<br>
+1 from me, though I prefer the `??=` spelling to match the `??` operator more closely.<br>
<span><font color="#888888"><br>
--<br>
Brent Royal-Gordon<br>
Architechies<br>
</font></span></div></div><div><div><br><span class="">
_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org" target="_blank">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>
</span></div></div></blockquote></div><br></div></div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=xV0JY-2FdZMnUMvSFtZnLiBPRTDDOSQf3-2FpH33HYOlBxHCmoqblRPu3QCZ5XRZruwnZ-2BGlsSXS7XHFBVRQTA-2B5NKBPecSkEMiEKqvTO5Loxd1XRhCgv-2BUMspC3PpyoJKT32QJ8AjHhSDZoG8JxbSxNRa0gU66lqARiwCJSzRUqw9vcSIIUcROAn9fZ1PyPletwh1fvNW7gUOt2JnzR-2FY7Cea7ouGlsomTcq5O1idJnkvA-3D" alt="" width="1" height="1" border="0" style="min-height:1px!important;width:1px!important;border-width:0!important;margin-top:0!important;margin-bottom:0!important;margin-right:0!important;margin-left:0!important;padding-top:0!important;padding-bottom:0!important;padding-right:0!important;padding-left:0!important">
<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>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div><span style="font-size:16px;line-height:19.2px"></span><span style="font-size:12.8px"> Wizard</span><br></div><div><a href="mailto:james@supmenow.com" target="_blank">james@supmenow.com</a></div><div>+44 7523 279 698</div></div></div></div></div></div>
</div>