<div dir="ltr">One possible caveat is with custom setters.<div><br></div><div>If "a" already has a value, does "a ??= b" 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: () -> T?) { if lhs == nil { lhs = rhs() } }</div><div><br></div><div>However, the use of "inout" will always cause the didSets to be triggered at the call site, when just using if-statements instead wouldn't have done so.</div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature"><div dir="ltr"><div>Jacob<br></div></div></div></div>
<br><div class="gmail_quote">On Tue, Dec 15, 2015 at 3:10 PM, Brent Royal-Gordon via swift-evolution <span dir="ltr"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">> I think that the existing syntax for “??” handles this need fairly well without requiring an additional assignment operator:<br>
><br>
> 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 class="HOEnZb"><font color="#888888"><br>
--<br>
Brent Royal-Gordon<br>
Architechies<br>
</font></span><div class="HOEnZb"><div class="h5"><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>
</div></div></blockquote></div><br></div></div>