<div dir="ltr"><div class="markdown-here-wrapper" style=""><p style="margin:0px 0px 1.2em!important">With <a href="https://github.com/thoughtbot/Runes">Runes</a>, this looks like:</p>
<pre style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;font-size:1em;line-height:1.2em;margin:1.2em 0px"><code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline;white-space:pre;overflow:auto;border-radius:3px;border:1px solid rgb(204,204,204);padding:0.5em 0.7em;display:block!important">(name1 &lt;^&gt; { &quot;\&quot;\($0)\&quot;&quot; }) ?? &quot;null&quot;
</code></pre><p style="margin:0px 0px 1.2em!important">Runes defines <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline">&lt;^&gt;</code> to have lower precedence than <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline">??</code>. Sadly, they all can’t be in the same precedence group due to right associativity of <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline">??</code>.</p>
<p style="margin:0px 0px 1.2em!important">2017-02-08 18:11 GMT+03:00 Tony Allevato via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;:</p>
<p style="margin:0px 0px 1.2em!important"></p><div class="markdown-here-exclude"><p></p><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">What you&#39;re asking for is already possible (avoiding the optional unwrap) by combining map() on Optional with ??:<div><br></div><div>```</div><div><div>let name1: String? = &quot;name&quot;</div><div>print(name1.map { &quot;\&quot;\($0)\&quot;&quot; } ?? &quot;null&quot;)  // prints &quot;\&quot;name\&quot;&quot;</div><div><br></div><div>let name2: String? = nil</div><div>print(name2.map { &quot;\&quot;\($0)\&quot;&quot; } ?? &quot;null&quot;)  // prints &quot;null&quot;</div><div>```</div><div><br></div><div>So I guess the question is, does simplifying that rise to the level of wanting a custom operator? I personally don&#39;t think it does, but I could see an argument being made that an operator with defined semantics might be a small amount clearer than map + ??. But I think the benefits would have to be very strong, though.</div><div><br></div><div>And as other folks have mentioned, having &quot;!&quot; in the operator name is somewhat misleading, since when I see that I expect a trap to occur in nil cases.</div></div></div></blockquote><p></p></div><p style="margin:0px 0px 1.2em!important"></p>
<div title="MDH:PGRpdiBjbGFzcz0iZ21haWxfZXh0cmEiPjxkaXYgY2xhc3M9ImdtYWlsX3F1b3RlIj5XaXRoIFtS
dW5lc10oPGEgaHJlZj0iaHR0cHM6Ly9naXRodWIuY29tL3Rob3VnaHRib3QvUnVuZXMiIHRhcmdl
dD0iX2JsYW5rIiBkYXRhLXNhZmVyZWRpcmVjdHVybD0iaHR0cHM6Ly93d3cuZ29vZ2xlLmNvbS91
cmw/aGw9cnUmYW1wO3E9aHR0cHM6Ly9naXRodWIuY29tL3Rob3VnaHRib3QvUnVuZXMmYW1wO3Nv
dXJjZT1nbWFpbCZhbXA7dXN0PTE0ODY2NjQ2MjYzNjcwMDAmYW1wO3VzZz1BRlFqQ05FdVdHZkNo
N0dVSnZUeFNSSF9FNnNKdGtYWENnIj5odHRwczovL2dpdGh1Yi5jb20vdGhvPHdicj51Z2h0Ym90
L1J1bmVzPC9hPiksIHRoaXMgbG9va3MgbGlrZTo8L2Rpdj48ZGl2IGNsYXNzPSJnbWFpbF9xdW90
ZSI+PGJyPjwvZGl2PjxkaXYgY2xhc3M9ImdtYWlsX3F1b3RlIj5gYGA8L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