<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">I suppose that you could interpret : as a separator, or you could interpret it as else or default. I have chosen the latter. It is up to us to decide how to interpret it because the ternary only has true and false.&nbsp;<div class=""><span class="" style="font-family: Menlo; color: rgb(187, 44, 162);"><br class=""></span></div><div class=""><span class="" style="font-family: Menlo; color: rgb(187, 44, 162);">let</span><font color="#008400" class="" style="font-family: Menlo;">&nbsp;fe = truthy == truth ?&nbsp;</font><font color="#272ad8" class=""><font face="Menlo" class="">“unlikely</font></font><font class=""><font color="#272ad8" face="Menlo" class="">” :</font><font face="Menlo" color="#008400" class="">&nbsp;</font></font><font color="#272ad8" face="Menlo" class="">“likely”</font></div><div class=""><br class=""></div><div class="">Some other nice things about using it as the default or else is that you can support syntaxes like the zero based index based one.</div><div class=""><br class=""></div><div class=""><div class=""><div class="" style="margin: 0px; line-height: normal;"><span class="" style="font-family: Menlo; color: rgb(187, 44, 162);">let</span><font face="Menlo" class="">&nbsp;fb = pickOne ?&nbsp;</font><font color="#d12f1b" face="Menlo" class="">“A",</font><font face="Menlo" class="">&nbsp;</font><span class="" style="font-family: Menlo; color: rgb(209, 47, 27);">"B"</span><font face="Menlo" class="">,&nbsp;</font><span class="" style="font-family: Menlo; color: rgb(209, 47, 27);">"C"</span><font face="Menlo" class="">,&nbsp;</font><span class="" style="font-family: Menlo; color: rgb(209, 47, 27);">"D"</span><font face="Menlo" class="">,&nbsp;</font><span class="" style="font-family: Menlo; color: rgb(209, 47, 27);">"E"</span><font face="Menlo" class="">,&nbsp;</font><span class="" style="font-family: Menlo; color: rgb(209, 47, 27);">"F"</span><font face="Menlo" class="">,&nbsp;</font><span class="" style="font-family: Menlo; color: rgb(209, 47, 27);">"G</span><font face="Menlo" class=""><font color="#d12f1b" class="">”</font>&nbsp;:&nbsp;</font><span class="" style="font-family: Menlo; color: rgb(209, 47, 27);">"Z"</span></div></div><div class=""><div class="" style="margin: 0px; line-height: normal;"><div class="" style="margin: 0px; line-height: normal;"><br class=""></div></div></div><div>this may be a non goal for some but I really think it could come in handy. Where the “Z” is selected if not 0-6. If we use the colon as the default or else case then this is possible. This does not break with the ternary tradition if you interpret the colon as default or else.&nbsp;</div><div><br class=""></div><div>Also, nicely, the switch form does not conflict with the last colon if we use the underscore to exhaustively list the cases because it technically does not need the : to be the default. So in that form, you would not have the default.&nbsp;</div><div><br class=""></div><div>Also, I agree with the sentiment that i would rather get something than nothing, even if that means having to have &nbsp;the redundancy of cases and default: but I really don’t like extra boilerplate and there is a risk that it won’t seem as big a win if you have to list all the cases out.&nbsp;</div><div><br class=""></div><div><br class=""></div><div><br class=""><blockquote type="cite" class=""><div class="">On Jan 6, 2016, at 9:07 PM, Charles Constant &lt;<a href="mailto:charles@charlesism.com" class="">charles@charlesism.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Hi Paul,&nbsp;<div class=""><br class=""></div><div class="">My opinion, atm, is that ":" as a separator is the best solution. True, it's not <b class="">Swift-like</b>, but neither is the existing ternary, which Chris wants to keep. On then other hand, "colon as separator" is extremely <b class="">ternary-like</b>.&nbsp;</div><div class=""><br class=""></div><div class="">So benefits of "colon as separator" as I see them:&nbsp;</div><div class=""><br class=""></div><div class="">- Syntax is <b class="">easy to remember</b> (as long as you're used to writing ternary expressions)</div><div class="">- Extremely <b class="">compact</b> syntax</div><div class="">- Each component is demarked by a special character, which I'm pretty sure makes any <b class="">chaining</b> possible</div><div class="">- <b class="">Easy to "market"</b> as a "new modification of ternary expressions in Swift" rather than a brand new construct&nbsp;</div><div class="">- <b class="">Somewhat intuitive</b>. The compact form and cryptic symbols mean a ternary isn't going to be self explanatory. But at least there's a call and response sort of logic to "condition <b class="">?</b>" followed by "case <b class="">!</b>"</div><div class=""><br class=""></div><div class="">That said, I don't want to dig my heels in about "colon as separator" version. If others don't like it, I support *any* version we've discussed in this thread, switch-like or ternary-like. As long as it means we do away with a preceding variable declaration and some of the repeated boilerplate... that's the important thing for me.<br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">&nbsp;&nbsp;</div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Wed, Jan 6, 2016 at 8:35 PM, Paul Ossenbruggen <span dir="ltr" class="">&lt;<a href="mailto:possen@gmail.com" target="_blank" class="">possen@gmail.com</a>&gt;</span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="">Hi Charles,<div class=""><br class=""></div><div class="">Chris, already said he did not like ? being used for ternary because it was already used for optionals. I think because of historical precedent it may be acceptable here.&nbsp; I have tried combos earlier with ! and got no support, admittedly not with the same usage as yours.&nbsp;</div><div class=""><br class=""></div><div class="">Do you really find it confusing not having a separator there? It is essentially a switch case without the word “case”. In my model the colon only indicates the “else” or “default” case, the other cases are separated by commas or whitespace. With my email taking the Swift Book examples and converting it from statement to expression form, I did not find any of them confusing, well maybe the first one, which found vowels and consonants, but that did not look that great in statement form either. .&nbsp;</div><div class=""><br class=""></div><div class="">if so maybe the | would be better as the separator because it would not change the switch like syntax:</div><div class=""><br class=""></div><div class=""><div style="font-family:Menlo;margin:0px;line-height:normal;color:rgb(0,132,0)" class=""><span class=""><div style="margin:0px;line-height:normal" class=""><span style="color:rgb(187,44,162)" class="">let</span><span style="" class="">&nbsp;numberSymbol:&nbsp;</span><span style="color:rgb(112,61,170)" class="">Character</span><span style="" class="">&nbsp;=&nbsp;</span><span style="color:rgb(209,47,27)" class="">"</span><span style="line-height:normal;font-family:'PingFang SC';color:rgb(209,47,27)" class="">三</span><span style="color:rgb(209,47,27)" class="">"</span><span style="" class="">&nbsp;&nbsp;</span>// Simplified Chinese for the number 3</div><div style="margin:0px;line-height:normal" class=""><span style="color:rgb(187,44,162)" class="">let</span>&nbsp;possibleIntegerValue:<span style="color:rgb(112,61,170)" class="">Int</span>? =&nbsp;<span style="color:rgb(79,129,135)" class="">numberSymbol</span>&nbsp;?</div></span><span class=""><div style="margin:0px;line-height:normal" class="">&nbsp; &nbsp;|&nbsp;<span style="color:rgb(209,47,27)" class="">"1"</span>,&nbsp;<span style="color:rgb(209,47,27)" class="">"</span><span style="line-height:normal;font-family:'Courier New';color:rgb(209,47,27)" class="">١</span><span style="color:rgb(209,47,27)" class="">"</span>,&nbsp;<span style="color:rgb(209,47,27)" class="">"</span><span style="line-height:normal;font-family:'PingFang SC';color:rgb(209,47,27)" class="">一</span><span style="color:rgb(209,47,27)" class="">"</span>,&nbsp;<span style="color:rgb(209,47,27)" class="">"</span><span style="line-height:normal;font-family:Ayuthaya;color:rgb(209,47,27)" class="">๑</span><span style="color:rgb(209,47,27)" class="">"</span>:&nbsp;<span style="color:rgb(39,42,216)" class="">1</span></div><div style="margin:0px;line-height:normal" class="">&nbsp; &nbsp;|&nbsp;<span style="color:rgb(209,47,27)" class="">"2"</span>,&nbsp;<span style="color:rgb(209,47,27)" class="">"</span><span style="line-height:normal;font-family:'Courier New';color:rgb(209,47,27)" class="">٢</span><span style="color:rgb(209,47,27)" class="">"</span>,&nbsp;<span style="color:rgb(209,47,27)" class="">"</span><span style="line-height:normal;font-family:'PingFang SC';color:rgb(209,47,27)" class="">二</span><span style="color:rgb(209,47,27)" class="">"</span>,&nbsp;<span style="color:rgb(209,47,27)" class="">"</span><span style="line-height:normal;font-family:Ayuthaya;color:rgb(209,47,27)" class="">๒</span><span style="color:rgb(209,47,27)" class="">"</span>:&nbsp;<span style="color:rgb(39,42,216)" class="">2</span></div><div style="margin:0px;line-height:normal" class="">&nbsp; &nbsp;|&nbsp;<span style="color:rgb(209,47,27)" class="">"3"</span>,&nbsp;<span style="color:rgb(209,47,27)" class="">"</span><span style="line-height:normal;font-family:'Courier New';color:rgb(209,47,27)" class="">٣</span><span style="color:rgb(209,47,27)" class="">"</span>,&nbsp;<span style="color:rgb(209,47,27)" class="">"</span><span style="line-height:normal;font-family:'PingFang SC';color:rgb(209,47,27)" class="">三</span><span style="color:rgb(209,47,27)" class="">"</span>,&nbsp;<span style="color:rgb(209,47,27)" class="">"</span><span style="line-height:normal;font-family:Ayuthaya;color:rgb(209,47,27)" class="">๓</span><span style="color:rgb(209,47,27)" class="">"</span>:&nbsp;<span style="color:rgb(39,42,216)" class="">3</span></div><div style="margin:0px;line-height:normal" class="">&nbsp; &nbsp;|&nbsp;<span style="color:rgb(209,47,27)" class="">"4"</span>,&nbsp;<span style="color:rgb(209,47,27)" class="">"</span><span style="line-height:normal;font-family:'Courier New';color:rgb(209,47,27)" class="">٤</span><span style="color:rgb(209,47,27)" class="">"</span>,&nbsp;<span style="color:rgb(209,47,27)" class="">"</span><span style="line-height:normal;font-family:'PingFang SC';color:rgb(209,47,27)" class="">四</span><span style="color:rgb(209,47,27)" class="">"</span>,&nbsp;<span style="color:rgb(209,47,27)" class="">"</span><span style="line-height:normal;font-family:Ayuthaya;color:rgb(209,47,27)" class="">๔</span><span style="color:rgb(209,47,27)" class="">"</span>:&nbsp;<span style="color:rgb(39,42,216)" class="">4</span></div><div style="margin:0px;line-height:normal" class="">&nbsp; &nbsp;|&nbsp;&nbsp;<span style="color:rgb(187,44,162)" class="">_</span>&nbsp;:&nbsp;<span style="color:rgb(187,44,162)" class="">nil</span></div><div style="margin:0px;line-height:normal" class=""><br class=""></div></span><span class=""><div style="margin:0px;line-height:normal;color:rgb(79,129,135)" class=""><span style="color:rgb(187,44,162)" class="">if</span><span style="" class="">&nbsp;</span><span style="color:rgb(187,44,162)" class="">let</span><span style="" class="">&nbsp;integerValue =&nbsp;</span>possibleIntegerValue<span style="" class="">&nbsp;{</span></div><div style="margin:0px;line-height:normal;color:rgb(209,47,27)" class=""><span style="" class="">&nbsp; &nbsp;&nbsp;</span><span style="color:rgb(61,29,129)" class="">print</span><span style="" class="">(</span>"The integer value of&nbsp;<span style="" class="">\</span>(<span style="color:rgb(79,129,135)" class="">numberSymbol</span>) is&nbsp;<span style="" class="">\</span>(<span style="" class="">integerValue</span>)."<span style="" class="">)</span></div><div style="margin:0px;line-height:normal" class="">}&nbsp;<span style="color:rgb(187,44,162)" class="">else</span>&nbsp;{</div><div style="margin:0px;line-height:normal;color:rgb(209,47,27)" class=""><span style="" class="">&nbsp; &nbsp;&nbsp;</span><span style="color:rgb(61,29,129)" class="">print</span><span style="" class="">(</span>"An integer value could not be found for&nbsp;<span style="" class="">\</span>(<span style="color:rgb(79,129,135)" class="">numberSymbol</span>)."<span style="" class="">)</span></div><div style="margin:0px;line-height:normal" class="">}</div></span></div><span class=""><div style="font-family:Menlo;margin:0px;line-height:normal;color:rgb(0,132,0)" class="">// prints "The integer value of&nbsp;<span style="line-height:normal;font-family:'PingFang SC'" class="">三</span>&nbsp;is 3.”</div></span></div><div class=""><br class=""></div><div class="">But I still don’t see it a necessary. &nbsp;perhaps that would allow removal of the parenthesis and I think this would get rejected as not looking very Swift like. Also single line form which isn’t bad:</div><div class=""><br class=""></div><div class=""><span class=""><div style="margin:0px;font-size:13px;line-height:normal;font-family:Arial;color:rgb(96,96,96)" class=""><b class=""><span style="white-space:pre-wrap" class="">        </span>let&nbsp;val&nbsp;=&nbsp;color&nbsp;?&nbsp;</b><span style="color:rgb(227,36,0)" class=""><b class="">.Red:</b></span><b class="">&nbsp;0xFF0000 |&nbsp;</b><span style="color:rgb(227,36,0)" class=""><b class="">.Green:</b></span><b class="">&nbsp;0x00FF00 |&nbsp;</b><b class="">&nbsp;</b><span style="color:rgb(227,36,0)" class=""><b class="">.Blue:</b></span><b class="">&nbsp;0x0000FF</b><b class="">&nbsp;|&nbsp;</b><span style="color:rgb(227,36,0)" class=""><b class="">_:</b></span><b class="">&nbsp;0xFFFFFF</b></div><div style="margin:0px;font-size:13px;line-height:normal;font-family:Arial;color:rgb(96,96,96)" class=""><br class=""></div></span><div class="">But still not sure the | adds that much.</div><div class=""><br class=""></div><div class=""><div style="margin:0px;font-size:13px;line-height:normal;font-family:Arial;color:rgb(96,96,96)" class=""><b class=""><span style="white-space:pre-wrap" class="">        </span>let&nbsp;val&nbsp;=&nbsp;color&nbsp;?&nbsp;</b><span style="color:rgb(227,36,0)" class=""><b class="">.Red:</b></span><b class="">&nbsp;0xFF0000,&nbsp;</b><span style="color:rgb(227,36,0)" class=""><b class="">.Green:</b></span><b class="">&nbsp;0x00FF00,&nbsp;</b><b class="">&nbsp;</b><span style="color:rgb(227,36,0)" class=""><b class="">.Blue:</b></span><b class="">&nbsp;0x0000FF,&nbsp;</b><b class="">&nbsp;</b><span style="color:rgb(227,36,0)" class=""><b class="">_:</b></span><b class="">&nbsp;0xFFFFFF</b></div><div class=""><br class=""></div>Or this is without the commas is still readable but maybe a little harder:</div><span class=""><div class=""><br class=""></div><div class=""><div style="margin:0px;font-size:13px;line-height:normal;font-family:Arial;color:rgb(96,96,96)" class=""><b class=""><span style="white-space:pre-wrap" class="">        </span>let&nbsp;val&nbsp;=&nbsp;color&nbsp;?&nbsp;</b><span style="color:rgb(227,36,0)" class=""><b class="">.Red:</b></span><b class="">&nbsp;0xFF0000&nbsp;</b><span style="color:rgb(227,36,0)" class=""><b class="">.Green:</b></span><b class="">&nbsp;0x00FF00&nbsp;</b><b class="">&nbsp;</b><span style="color:rgb(227,36,0)" class=""><b class="">.Blue:</b></span><b class="">&nbsp;0x0000FF&nbsp;</b><b class="">&nbsp;</b><span style="color:rgb(227,36,0)" class=""><b class="">_:</b></span><b class="">&nbsp;0xFFFFFF</b></div><div class=""><b class=""><br class=""></b></div></div></span><div class="">One other thing, I would still prefer the control value inside the brace rather than out front, but I see that most people still want it out front and since it would be a breaking change for ternary, I have kind of backed off it but I think this is still clearer because the control value is not floating out in front.&nbsp;</div><div class=""><br class=""></div><div class=""><div style="margin:0px;font-size:13px;line-height:normal;font-family:Arial;color:rgb(96,96,96)" class=""><b class=""><span style="white-space:pre-wrap" class="">        </span>let&nbsp;val&nbsp;= &nbsp;?(color,&nbsp;</b><span style="color:rgb(227,36,0)" class=""><b class="">.Red:</b></span><b class="">&nbsp;0xFF0000,&nbsp;</b><span style="color:rgb(227,36,0)" class=""><b class="">.Green:</b></span><b class="">&nbsp;0x00FF00,&nbsp;</b><b class="">&nbsp;</b><span style="color:rgb(227,36,0)" class=""><b class="">.Blue:</b></span><b class="">&nbsp;0x0000FF,&nbsp;</b><b class="">&nbsp;</b><span style="color:rgb(227,36,0)" class=""><b class="">_:</b></span><b class="">&nbsp;0xFFFFFF)</b></div><div class=""><div class="h5"><div class=""><b class=""><br class=""></b></div><blockquote type="cite" class=""><div class="">On Jan 6, 2016, at 7:06 PM, Charles Constant &lt;<a href="mailto:charles@charlesism.com" target="_blank" class="">charles@charlesism.com</a>&gt; wrote:</div><br class=""><div class=""><div dir="ltr" class=""><div class=""><div class=""><div style="font-size:13px;margin:0px;line-height:normal;font-family:Arial" class=""><span style="font-family:arial,sans-serif;font-size:small" class="">&gt;&nbsp;</span><span style="font-family:arial,sans-serif" class="">I see what you are trying to do, because of the colon being both used for switch cases and&nbsp;</span><br class=""></div></div></div><div class=""><span style="font-size:13px" class="">&gt; separators for the ternary and so there needs to be a new character for each case. &nbsp;</span></div><div class=""><span style="font-size:13px" class="">&gt; I am not sure that putting colons between each case is really necessary though.</span></div><div class=""><span style="font-size:13px" class=""><br class=""></span></div><div class="">Most of us (including you and I) like a form that starts with " let val = condition ? " like the existing ternary. Let's say a proposal like that gets accepted... I really believe "colons as separators" is the best idea in the case. Otherwise, it gets pretty confusing.. we'll have the existing ternary where a colon does one thing, and our new "extra ternary" where it does something else.&nbsp;</div><div class=""><br class=""></div><div class="">This is why I like colons (this won't make sense unless your email has rich text to show the colors):&nbsp;</div><div class=""><br class=""></div><div class=""><div class=""><div style="margin:0px;font-size:13px;line-height:normal;font-family:Arial;color:rgb(96,96,96)" class=""><b class=""><span style="white-space:pre-wrap" class="">        </span>let&nbsp;val&nbsp;=&nbsp;color&nbsp;?&nbsp;</b></div><div style="margin:0px;font-size:13px;line-height:normal;font-family:Arial;color:rgb(96,96,96)" class=""><b class=""><span style="white-space:pre-wrap" class="">                </span></b><span style="color:rgb(227,36,0)" class=""><b class="">.Red&nbsp;!</b></span><b class="">&nbsp;<span style="white-space:pre-wrap" class="">        </span>0xFF0000&nbsp;:&nbsp;</b></div><div style="margin:0px;font-size:13px;line-height:normal;font-family:Arial;color:rgb(96,96,96)" class=""><b class=""><span style="white-space:pre-wrap" class="">                </span></b><span style="color:rgb(227,36,0)" class=""><b class="">.Green&nbsp;!</b></span><b class="">&nbsp;<span style="white-space:pre-wrap" class="">        </span>0x00FF00&nbsp;:&nbsp;</b></div><p style="font-size:13px;margin:0px;line-height:normal;font-family:Arial" class="">


</p><div style="margin:0px;font-size:13px;line-height:normal;font-family:Arial;color:rgb(96,96,96)" class=""><b class=""><span style="white-space:pre-wrap" class="">                </span></b><span style="color:rgb(227,36,0)" class=""><b class="">_&nbsp;!</b></span><b class="">&nbsp;<span style="white-space:pre-wrap" class="">                </span>0xFFFFFF</b></div></div></div><div class=""><b class=""><br class=""></b></div><div class="">... no syntax here different from the existing except the addition "&nbsp;<span style="font-family:Arial;font-size:13px;color:rgb(227,36,0)" class=""><b class="">.Red&nbsp;!</b></span><span style="font-size:13px;font-family:Arial" class="">&nbsp;</span>". As for the exclamation... Swift already uses an exclamation for a billion other things, which is unfortunate. But the same can be said of "?" and that's already used in a "switch" without causing confusion.&nbsp;</div><div class=""><span style="font-size:13px" class=""><br class=""></span></div><div class=""><div style="font-size:13px;margin:0px;line-height:normal;font-family:Arial" class="">&gt; To point 1: I agree it needs a new name, I came up with the “demux expression”&nbsp;</div><div style="font-size:13px;margin:0px;line-height:normal;font-family:Arial" class="">&gt; but maybe there is a better name.<br class=""></div></div><div class=""><span style="font-size:13px" class=""><br class=""></span></div><div class="">Has anyone suggested "multiary expression" yet? Seems in keeping with "ternary"<br class=""></div><div class=""><span style="font-size:13px" class=""><br class=""></span></div><div class=""><span style="font-size:13px" class=""><br class=""></span></div><div class=""><span style="font-size:13px" class=""><br class=""></span></div><div class=""><span style="font-size:13px" class=""><br class=""></span></div><div class=""><span style="font-size:13px" class=""><br class=""></span></div><div class=""><br class=""></div></div>
</div></blockquote></div></div></div><br class=""></div></div></blockquote></div><br class=""></div>
</div></blockquote></div><br class=""></div></body></html>