<div dir="ltr"><span><div id="bloop_customfont" style="color:rgb(0,0,0);font-family:Helvetica,Arial;margin:0px">I agree that ternary can make code unreadable, especially so with the ‘?’. I personally like the Haskel option the most, but it introduces a new keyword ‘then’, which isn’t great either. Python’s &quot;y if x else z&quot; is therefore, in my opinion, the best alternative.</div><div id="bloop_customfont" style="color:rgb(0,0,0);font-family:Helvetica,Arial;margin:0px"><br></div><div id="bloop_customfont" style="color:rgb(0,0,0);font-family:Helvetica,Arial;margin:0px">Also, I found it interesting how split the Rust community was about removing the ternary operator.</div><div id="bloop_customfont" style="color:rgb(0,0,0);font-family:Helvetica,Arial;margin:0px"><br></div><div id="bloop_customfont" style="color:rgb(0,0,0);font-family:Helvetica,Arial;margin:0px"><span style="font-family:helvetica,arial">— </span></div><div id="bloop_sign_1449203852020918016" class="bloop_sign" style="color:rgb(0,0,0);font-family:Helvetica,Arial"><div style="font-family:helvetica,arial">Dan Appel</div></div></span></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Dec 3, 2015 at 7:58 PM J. Cheyo Jimenez &lt;<a href="mailto:cheyo@masters3d.com">cheyo@masters3d.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><span style="font-size:12.8px">Would you consider replacing the C style ?: ternary operator to something that does not use the question mark and colon ? </span><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">The use of &quot;?&quot; can be confusing when speed reading code with optionals. </div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">Consider this code as somebody learning swift as their first language.</div><div style="font-size:12.8px"><p><font face="monospace, monospace">let result = !condition ? 1 : 2</font></p></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">Some alternatives:</div><div style="font-size:12.8px"><div><br></div><div>Haskel <div><div dir="ltr" style="direction:ltr;color:rgb(37,37,37);font-family:sans-serif;font-size:14px;line-height:14.9333px;background:rgb(248,248,248)"><pre style="white-space:pre-wrap;font-family:monospace,Courier;color:black;border:1px solid rgb(221,221,221);padding:1em;line-height:1.3em;background-color:rgb(249,249,249)"><span style="color:rgb(0,128,0);font-weight:bold">if</span> predicate <span style="color:rgb(0,128,0);font-weight:bold">then</span> expr1 <span style="color:rgb(0,128,0);font-weight:bold">else</span> expr2</pre></div><div>Python</div></div><div><pre style="white-space:pre-wrap;font-family:monospace,Courier;color:black;border:1px solid rgb(221,221,221);padding:1em;line-height:1.3em;font-size:14px;background-color:rgb(249,249,249)">result <span style="color:rgb(102,102,102)">=</span> x <span style="color:rgb(0,128,0);font-weight:bold">if</span> a <span style="color:rgb(102,102,102)">&gt;</span> b <span style="color:rgb(0,128,0);font-weight:bold">else</span> y</pre></div><div>The advantage of not using the question mark is that the language will be more consistency on the use of &quot;?&quot; to mean only optionals. <br></div><div><br></div><div><br></div><div>References:</div><div><a href="https://devforums.apple.com/message/1020139#1020139" target="_blank">https://devforums.apple.com/message/1020139#1020139</a></div></div></div><div style="font-size:12.8px"><a href="https://github.com/rust-lang/rust/issues/1698#issuecomment-3705066" target="_blank">https://github.com/rust-lang/rust/issues/1698#issuecomment-3705066</a></div></div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=4Q3dO0ELn940F2HNV6NWP3n6-2BFmLgXvEeytAtbr-2BgeDYoD5tpBTS72h2nPdoesBjFIHECaHIxYh10FYCXUeWQ65fPIrQZyTNAdleeXCQ64naCq-2BRo4e2zXf0J9A2HRmL88OFXVfBZ5quTXBpurvrqBBs4d-2ByKIvlmbh88TYRH4UfeDBg9-2Fm70jQ1K-2FTBCibgE3e1ZTsN44r9UpWEyJfJ-2F3E-2Fhz7mL2i3piK7DxnoOdI-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>
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>
</blockquote></div>