<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>I agree that using ? for ternary feels.. uncomfortable in Swift. I wouldn't mind seeing Python-style or just eliminating it entirely in favor of simplicity.</div><div id="AppleMailSignature"><br></div><div id="AppleMailSignature">l8r</div><div id="AppleMailSignature">Sean<br></div><div><br>On Dec 3, 2015, at 10:48 PM, Dan Appel &lt;<a href="mailto:dan.appel00@gmail.com">dan.appel00@gmail.com</a>&gt; wrote:<br><br></div><blockquote type="cite"><div><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 "y if x else z" 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">—&nbsp;</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 ?:&nbsp;ternary operator to something that does not use the question mark and colon ?&nbsp;</span><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">The use of "?" can be confusing when speed reading code with optionals.&nbsp;</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&nbsp;result = !condition&nbsp;?&nbsp;1&nbsp;:&nbsp;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&nbsp;<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 "?" to mean only optionals.&nbsp;<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>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=CzM39owGTpkJ1zyGXnrRVEXja65D5KHvjV3-2BNib8-2FALErD0kiUUIMIXRwdeL5Lu76KgH2bdx5yKs2bSajEksH7zgA3iXmq0rXx62UiivBwrhmvKJ2lmUUvw-2F1goy53ob9w0N-2B043Vqbsv4aPVvPG12sD1tuiB1iZXAJIXUr6PdM3alK-2Fg1QSW0tRJlIaq-2BL1Q9kmi4L-2BquSs5eiGROE3kA45gCSlnV2ljaEzqH8fWPY-3D" alt="" width="1" height="1" border="0" style="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;">
</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>swift-evolution mailing list</span><br><span><a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br></div></blockquote></body></html>