<div dir="ltr">"<span style="font-size:13px"> assign x to a if x is non-zero, otherwise make it equal to y</span>"<div><br></div><div>You can't "if" anything other than a Bool.</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jan 6, 2016 at 11:09 PM, John Randolph <span dir="ltr"><<a href="mailto:jcr@icloud.com" target="_blank">jcr@icloud.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br>
> On Jan 6, 2016, at 10:18 PM, Charles Constant via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br>
><br>
> let fb = pickOne ? “A" : "B" : "C" : "D" : "E" : "F" : "G” : _ ! "Z"<br>
><br>
<br>
</span>I think it’s worth mentioning that in C today (both in GCC and Clang), we can use the ternary operator in a shortened fashion like so:<br>
<br>
a = x ?: y;<br>
<br>
which is equivalent to:<br>
<br>
a = x ? x : y;<br>
<br>
<br>
Meaning, assign x to a if x is non-zero, otherwise make it equal to y.<br>
<br>
This construct occurs all over the place in my Obj-C code, and porting that to Swift today is perfectly straightforward. If the ?: operator becomes the ?:::::: operator, then does this very common shorthand use of the existing ternary operator become impossible?<br>
<br>
I’m for keeping the ternary operator as it is. Expanding it into a poor man’s switch() is unnecessary and has definite drawbacks.<br>
<br>
-jcr</blockquote></div><br></div>