<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div></div><div>Plenty of languages have something along these lines, however the syntax isn't standard and therefore I don't see that ?? is well established. How can it be, if languages all do their own thing? Note: I wasn't proposing eliminating the concept, just suggesting that it isn't worthy of an operator and an operator tends to be invisible in an expression where as a method call isn't. </div><div><br>On 26 Jan 2016, at 2:35 PM, Trent Nadeau <<a href="mailto:tanadeau@gmail.com">tanadeau@gmail.com</a>> wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr">Null/nil coalescing operators are used across several languages (see <a href="https://en.wikipedia.org/wiki/Null_coalescing_operator">https://en.wikipedia.org/wiki/Null_coalescing_operator</a>) The ?? operator in particular is also used for this purpose in C# and PHP 7.</div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jan 25, 2016 at 9:43 PM, Howard Lovatt 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">I am no fan of the ?? operator since it tends to disappear in an expression, a bit like ?: does, and it fails the test of being well known or well established (see API guidelines). Also it isn't used often, therefore I would suggest a method, ifNil, added to Optional instead:<br>
<br>
x.ifNil(false)<br>
<br>
> On 26 Jan 2016, at 1:32 PM, Craig Cruden via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br>
><br>
> I agree - ?? looks better — at least better than the example shown…. the suggested replacement looks messy and is not an improvement (occasional swift coder - as such I am less biased than other Swiftees).<br>
><br>
><br>
>> On 2016-01-26, at 9:28:50, Erica Sadun via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br>
>><br>
>> Not loving this. I'm quite happy with ??-coalescing and don't see<br>
>> a compelling reason it needs to be "cleaner". I find your suggested<br>
>> enhancement less readable. Looks like an optional chaining across<br>
>> a function.<br>
>><br>
>> -- E<br>
>><br>
>>> On Jan 25, 2016, at 7:03 PM, Amir Michail via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br>
>>><br>
>>> Examples:<br>
>>><br>
>>> * instead of x ?? false, you would have x?(false)<br>
>>> * instead of x?.isEmpty ?? false, you would have x?(false).isEmpty<br>
>>><br>
>>> I think this change would result in cleaner looking code.<br>
>>><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>
>><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>
> _______________________________________________<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>
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>
</div></blockquote></body></html>