<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="">Good feedback, I am all for making it feel more like swift. Any ideas would be welcome. I will also try to come up with some myself.&nbsp;<div class=""><br class=""></div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jan 4, 2016, at 12:34 PM, Rod Brown &lt;<a href="mailto:rodney.brown6@icloud.com" class="">rodney.brown6@icloud.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="content-type" content="text/html; charset=utf-8" class=""><div dir="auto" class=""><div class="">For all the proposals I've seen on this topic, I have to say -1.</div><div class=""><br class=""></div><div class="">While I agree with the notions surrounding this operator, I've yet to see a better alternative presented, and none that feel truly Swift.</div><div class=""><br class=""></div><div class="">If someone has a great proposal, though, I look forward to seeing it.</div><div class=""><br class="">- Rod</div><div class=""><br class="">On 5 Jan 2016, at 7:28 AM, Howard Lovatt via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""><br class=""></div><blockquote type="cite" class=""><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class="">-1 for me. None of it looks or feels like Swift, more like Haskell. I would prefer a library solution for now and remove ?: from the language and add a which into the standard library and see how that goes and if there is need for more.<div class=""><br class=""><div class="">
Sorry,<br class=""><br class="">Howard.<br class=""></div><div class=""><br class=""></div><div class=""><blockquote type="cite" class=""><div class="">On 5 Jan 2016, at 7:24 AM, Paul Ossenbruggen via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Any feedback on this? I am rethinking the idea of #( because of the # prior usage as a preprocessor directive, but like how it stands out and has a meaning. &nbsp;If no feedback, does it make sense to update my proposal with these ideas? Or does this feel like the wrong direction.&nbsp;</span><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br class=""><div class=""><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Dec 30, 2015, at 8:52 AM, Paul Ossenbruggen &lt;<a href="mailto:possen@gmail.com" class="">possen@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""><div class="" style="margin: 0px; line-height: normal;"><div class="" style="margin: 0px; line-height: normal;">Some more ideas, this moves away from the notion that we should make it look really close to the ternary but keeps all the benefits of the ternary and improves upon it. Since I have been suggesting a breaking change, it is a good time to rethink it a bit. With this idea a horizontal line (double-dash) separates the control value from the choices, the vertical line (bar) indicates none of the above.&nbsp;</div><div class="" style="margin: 0px; line-height: normal;"><br class=""></div><div class="" style="margin: 0px; line-height: normal;">Rather than use the ?( as I have suggested in the past, I think #( works here, where you can think of it as a numerical index. The advantage of this is, it stands out better and leaves ? for optionals only. This works well with the list form. In the enum case the index is the enum key. I can see that this however may be a problem because # is used for preprocessor like directives. I am suggesting though just the #( sequence is treated differently. Or the ?( is fine with me as well.</div><div class="" style="margin: 0px; line-height: normal;"><br class=""></div><div class="" style="margin: 0px; line-height: normal;">I have gone through a lot of options, some others I looked at are !( which could be read as "match stick” paren, where the word “match” matches a case, I am pretty sure that would not be considered any better than ?( because it is used for optionals. Another is “witch hat paren” ^( which can be read as “which”. &nbsp;This might create a parse problem with "power of" though, which maybe using ^[ (hat square bracket) could resolve that but not sure if that would create other problems. Some other choices would be &amp;( &nbsp;and @( but did not choose them because &nbsp;they don’t have meaning to me but they do have the advantage of standing out like the #(.&nbsp;</div><div class="" style="font-family: Menlo; margin: 0px; line-height: normal;"><br class=""></div><div class="" style="font-family: Menlo; margin: 0px; line-height: normal;"><span class="" style="color: rgb(187, 44, 162);">let</span><span class="Apple-converted-space">&nbsp;</span>fa = #(truth --&nbsp;<span class="" style="color: rgb(39, 42, 216);">1</span><span class="Apple-converted-space">&nbsp;</span>|<span class="Apple-converted-space">&nbsp;</span><span class="" style="color: rgb(39, 42, 216);">0</span>)<span class="Apple-converted-space">&nbsp;</span><font color="#77bb41" class="">// boolean case</font>.&nbsp;</div><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=""><span class="Apple-converted-space">&nbsp;</span>fb = #(pickOne --&nbsp;</font><span class="" style="font-family: Menlo; color: rgb(209, 47, 27);">"A"</span><font face="Menlo" class="">,<span class="Apple-converted-space">&nbsp;</span></font><span class="" style="font-family: Menlo; color: rgb(209, 47, 27);">"B"</span><font face="Menlo" class="">,<span class="Apple-converted-space">&nbsp;</span></font><span class="" style="font-family: Menlo; color: rgb(209, 47, 27);">"C"</span><font face="Menlo" class="">,<span class="Apple-converted-space">&nbsp;</span></font><span class="" style="font-family: Menlo; color: rgb(209, 47, 27);">"D"</span><font face="Menlo" class="">,<span class="Apple-converted-space">&nbsp;</span></font><span class="" style="font-family: Menlo; color: rgb(209, 47, 27);">"E"</span><font face="Menlo" class="">,<span class="Apple-converted-space">&nbsp;</span></font><span class="" style="font-family: Menlo; color: rgb(209, 47, 27);">"F"</span><font face="Menlo" class="">,<span class="Apple-converted-space">&nbsp;</span></font><span class="" style="font-family: Menlo; color: rgb(209, 47, 27);">"G"</span><font face="Menlo" class=""><span class="Apple-converted-space">&nbsp;</span>|<span class="Apple-converted-space">&nbsp;</span></font><span class="" style="font-family: Menlo; color: rgb(209, 47, 27);">"Z</span><font color="#d12f1b" face="Menlo" class="">”</font><font face="Menlo" class="">)<span class="Apple-converted-space">&nbsp;</span><font color="#669c35" class="">// list form, pick index, zero based</font>.&nbsp;</font></div><div class="" style="font-family: Menlo; margin: 0px; line-height: normal;"><span class="" style="color: rgb(187, 44, 162);">let</span><span class="Apple-converted-space">&nbsp;</span>fc = #(color -- .Red:<span class="Apple-converted-space">&nbsp;</span><span class="" style="color: rgb(39, 42, 216);">0xFF0000</span>, .Green:<span class="Apple-converted-space">&nbsp;</span><span class="" style="color: rgb(39, 42, 216);">0x00FF00</span>, .Blue:<span class="Apple-converted-space">&nbsp;</span><span class="" style="color: rgb(39, 42, 216);">0x0000FF</span><span class="Apple-converted-space">&nbsp;</span>|<span class="Apple-converted-space">&nbsp;</span><span class="" style="color: rgb(39, 42, 216);">0xFFFFFF</span>)<span class="Apple-converted-space">&nbsp;</span><font color="#669c35" class="">// enum form.</font></div><div class="" style="font-family: Menlo; margin: 0px; line-height: normal;"><span class="" style="color: rgb(187, 44, 162);">let</span>&nbsp;fd = #(color --&nbsp;.Red: &nbsp; &nbsp;<span class="" style="color: rgb(39, 42, 216);">0xFF0000</span>,&nbsp;</div><div class="" style="font-family: Menlo; margin: 0px; line-height: normal;">&nbsp;<span class="Apple-converted-space">&nbsp;</span><span class="Apple-tab-span" style="white-space: pre;">        </span>&nbsp; &nbsp; &nbsp;&nbsp;<span class="Apple-tab-span" style="white-space: pre;">        </span>&nbsp; &nbsp;&nbsp;.Green: &nbsp;<span class="" style="color: rgb(39, 42, 216);">0x00FF00</span>,&nbsp;</div><div class="" style="font-family: Menlo; margin: 0px; line-height: normal;"><span class="Apple-tab-span" style="white-space: pre;">        </span>&nbsp;<span class="Apple-tab-span" style="white-space: pre;">        </span>&nbsp; &nbsp;&nbsp;.Blue: &nbsp;<span class="Apple-converted-space">&nbsp;</span><span class="" style="color: rgb(39, 42, 216);">0x0000FF</span>&nbsp;</div><div class="" style="font-family: Menlo; margin: 0px; line-height: normal;">&nbsp; &nbsp; &nbsp; &nbsp;<span class="Apple-converted-space">&nbsp;</span><span class="Apple-tab-span" style="white-space: pre;">        </span>&nbsp; &nbsp;&nbsp;|&nbsp;<span class="" style="color: rgb(39, 42, 216);">0xFFFFFF</span>)<span class="Apple-converted-space">&nbsp;</span><font color="#669c35" class="">// enum multiline, default: can be used here if preferred.</font></div><div class="" style="font-family: Menlo; margin: 0px; line-height: normal;"><div class="" style="margin: 0px; line-height: normal;"><span class="" style="color: rgb(187, 44, 162);">let</span>&nbsp;fe = #(color -- .Red: &nbsp; &nbsp;<span class="" style="color: rgb(39, 42, 216);">0xFF0000</span>,&nbsp;</div><div class="" style="margin: 0px; line-height: normal;">&nbsp;&nbsp;<span class="Apple-tab-span" style="white-space: pre;">        </span>&nbsp; &nbsp; &nbsp;&nbsp;<span class="Apple-tab-span" style="white-space: pre;">        </span>&nbsp; &nbsp;&nbsp;.Green: &nbsp;<span class="" style="color: rgb(39, 42, 216);">0x00FF00</span>,&nbsp;</div><div class="" style="margin: 0px; line-height: normal;"><span class="Apple-tab-span" style="white-space: pre;">        </span>&nbsp;<span class="Apple-tab-span" style="white-space: pre;">        </span>&nbsp; &nbsp;&nbsp;.Blue: &nbsp;&nbsp;<span class="" style="color: rgb(39, 42, 216);">0x0000FF</span>)&nbsp;<span class="" style="color: rgb(102, 156, 53);">// if all cases handled, the last bar is optional</span></div><div class="" style="margin: 0px; line-height: normal;"><span class="" style="color: rgb(102, 156, 53);"><br class=""></span></div></div><div class="" style="margin: 0px; line-height: normal;">This visually kind of represents what is going on. Horizontal-line directs eye to one of the normal choices. Vertical-line says none found stop looking and do the otherwise choice. Kind of like a train switch.&nbsp;</div><div class="" style="margin: 0px; line-height: normal;"><br class=""></div><div class="" style="margin: 0px; line-height: normal;">The strong feedback was that a replacement has to be usable in places where a ternary could be used. So it needs to work on a single line (and multiline) and needs to be compact. By having a compact, “else" that is possible on a single line.&nbsp;</div><div class="" style="font-family: Menlo; margin: 0px; line-height: normal;"><br class=""></div><div class="" style="margin: 0px; line-height: normal;">Comparisons to ternary and other approaches:</div><div class="" style="margin: 0px; line-height: normal;">• It is very concise like ternary and can fit in places that a ternary does.</div><div class="" style="margin: 0px; line-height: normal;">• The horizontal line serves to provide a place to align the choices to pick from, not as necessary with ternary.&nbsp;</div><div class="" style="margin: 0px; line-height: normal;">• The vertical line stops the eye and indicates this is the “else” or “default” choice, the colon does that in ternary but the bar stands out more.</div><div class="" style="margin: 0px; line-height: normal;">• The parens group the expression, in a way that the ternary does not. With a ternary it is not until you get to the question mark and the barely visible colon that you realize it is a ternary.&nbsp;</div><div class="" style="margin: 0px; line-height: normal;">• The #( indicates immediately that the expression has started unlike a ternary.&nbsp;</div><div class="" style="margin: 0px; line-height: normal;">• #( clearly show beginning and end of the construct so that it is immediately identifiable unlike ternary.</div><div class="" style="margin: 0px; line-height: normal;">• Makes quick one line conversions easily achievable just as ternary can but allowing more than just boolean. &nbsp;</div><div class="" style="margin: 0px; line-height: normal;">• The “else” choice is always last and is compactly represented with vertical bar like ternary but more visible. This also differs from the switch statement form, in that it is much more compact than “default:"</div><div class="" style="margin: 0px; line-height: normal;">• The dash does not create a double colon for enum case as was mentioned as a problem in previous designs.</div><div class="" style="margin: 0px; line-height: normal;">• All data types for the control are handled the same way, like ternary but now supports more than boolean, it supports any enumerable tope.</div><div class="" style="margin: 0px; line-height: normal;">• The list form looks like a Array sort of, the enum form looks sort of like a Dictionary, this should make it seem familiar.</div><div class="" style="margin: 0px; line-height: normal;">• The enum form also supports pattern matching. (see below for examples). Which ternary does not.</div><div class="" style="margin: 0px; line-height: normal;">• The vast majority of switch statements, at least that I typically use, could be done with this and be much more compact and concise. However if your needs are more complex, then the switch statement is still available.&nbsp;</div><div class="" style="margin: 0px; line-height: normal;">• You get the benefits of automatic type inference where switch statements used to assign an expression result don’t let you.</div><div class="" style="margin: 0px; line-height: normal;">• It removes a lot of duplicated code compared to a switch statement assigning an expression result.&nbsp;</div><div class="" style="margin: 0px; line-height: normal;">• It makes it clear that the result of the expression can be a “let” where less experienced users may think a “var" is required in a switch statement.</div><div class="" style="margin: 0px; line-height: normal;">• The name binding and assignment occurs in one step unlike the switch statement, when used to assign an expression result.&nbsp;</div><div class="" style="margin: 0px; line-height: normal;">• It always returns a result of an expression like ternary does and will enforce that the result is a the same type.&nbsp;</div><div class="" style="margin: 0px; line-height: normal;">• Like ternary leaves the formatting choice to the developer for multiline and single-line but easily handles both.</div><div class="" style="margin: 0px; line-height: normal;">• Searchable with web search unlike ternary.&nbsp;</div><div class="" style="margin: 0px; line-height: normal;">• Enum uses the same format as the familiar switch syntax which ternary does not.</div><div class="" style="margin: 0px; line-height: normal;">• #( stands out more than ?( in my earlier designs.<span class="" style="font-family: Menlo;">&nbsp;</span></div><div class="" style="font-family: Menlo; margin: 0px; line-height: normal;"><br class=""></div></div></div><div class="">The difference between this and the switch statement is that this deals only in single expressions for each case. There can only be one expression that gets selected by the control input. This simplifies things compared to a switch statement there are not multiple statements to list afterwards and it does not need the word “case" before each part of the choice to separate each list of statements. This makes it so that it can be much more compact and means the word “case” is not necessary.&nbsp;</div><div class=""><br class=""></div><div class="">Below I go through a bunch of comparisons to statement form, vs new expression also different formatting options:</div><div class=""><br class=""></div><div class=""><div class="" style="margin: 0px; line-height: normal; font-family: Menlo;"><span class="" style="color: rgb(187, 44, 162);">let</span><span class="Apple-converted-space">&nbsp;</span>res :<span class="Apple-converted-space">&nbsp;</span><span class="" style="color: rgb(112, 61, 170);">Int</span></div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo; color: rgb(187, 44, 162);">switch<span class=""><span class="Apple-converted-space">&nbsp;</span></span><span class="" style="color: rgb(79, 129, 135);">color</span><span class=""><span class="Apple-converted-space">&nbsp;</span>{</span></div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp;<span class="Apple-converted-space">&nbsp;</span><span class="" style="color: rgb(187, 44, 162);">case</span><span class="Apple-converted-space">&nbsp;</span>.Red:<span class="Apple-converted-space">&nbsp;</span><span class="" style="color: rgb(79, 129, 135);">res</span><span class="Apple-converted-space">&nbsp;</span>=<span class="Apple-converted-space">&nbsp;</span><span class="" style="color: rgb(39, 42, 216);">0xFF0000</span></div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp;<span class="Apple-converted-space">&nbsp;</span><span class="" style="color: rgb(187, 44, 162);">case</span><span class="Apple-converted-space">&nbsp;</span>.Green:<span class="Apple-converted-space">&nbsp;</span><span class="" style="color: rgb(79, 129, 135);">res</span><span class="Apple-converted-space">&nbsp;</span>=&nbsp;<span class="" style="color: rgb(39, 42, 216);">0x00FF00</span></div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp;<span class="Apple-converted-space">&nbsp;</span><span class="" style="color: rgb(187, 44, 162);">case</span><span class="Apple-converted-space">&nbsp;</span>.Blue:<span class="Apple-converted-space">&nbsp;</span><span class="" style="color: rgb(79, 129, 135);">res</span><span class="Apple-converted-space">&nbsp;</span>=<span class="Apple-converted-space">&nbsp;</span><span class="" style="color: rgb(39, 42, 216);">0x0000FF</span></div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo; color: rgb(187, 44, 162);">default<span class="">:</span></div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo; color: rgb(39, 42, 216);"><span class="">&nbsp; &nbsp;<span class="Apple-converted-space">&nbsp;</span></span><span class="" style="color: rgb(79, 129, 135);">res</span><span class=""><span class="Apple-converted-space">&nbsp;</span>=<span class="Apple-converted-space">&nbsp;</span></span>0xFFFFFF</div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo;">}</div></div><div class=""><br class=""></div><div class="">With the new expression:</div><div class=""><br class=""></div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo;"><span class="" style="color: rgb(187, 44, 162);">let</span><span class="Apple-converted-space">&nbsp;</span>res = #(<span class="" style="color: rgb(79, 129, 135);">color --</span>&nbsp;.Red: &nbsp;&nbsp;<span class="" style="color: rgb(39, 42, 216);">0xFF0000</span></div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp;<span class="Apple-converted-space">&nbsp;</span><span class="Apple-tab-span" style="white-space: pre;">                </span>&nbsp; &nbsp; &nbsp;.Green:&nbsp;<span class="" style="color: rgb(39, 42, 216);">0x00FF00</span></div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;.Blue: &nbsp;<span class="" style="color: rgb(39, 42, 216);">0x0000FF</span></div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo;"><span class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><font color="#4f8187" class="">|&nbsp;</font><font color="#272ad8" class="">0xFFFFFF</font>}</div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo;"><br class=""></div><div class="" style="margin: 0px; line-height: normal;">This uses a where clause with existing statement:<span class="" style="font-family: Menlo;">&nbsp;</span></div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo;"><br class=""></div><div class="" style="margin: 0px; line-height: normal;"><div class="" style="margin: 0px; line-height: normal;"><div class="" style="margin: 0px; line-height: normal; font-family: Menlo;"><span class="" style="color: rgb(187, 44, 162);">let</span>&nbsp;res :&nbsp;<span class="" style="color: rgb(112, 61, 170);">Int</span></div><div class="" style="font-family: Menlo; color: rgb(187, 44, 162); margin: 0px; line-height: normal;">switch<span class=""><span class="Apple-converted-space">&nbsp;</span></span><span class="" style="color: rgb(79, 129, 135);">color</span><span class=""><span class="Apple-converted-space">&nbsp;</span>{</span></div><div class="" style="font-family: Menlo; margin: 0px; line-height: normal;"><span class="" style="color: rgb(187, 44, 162);">&nbsp; &nbsp; case .</span>Red<span class="Apple-converted-space">&nbsp;</span><font color="#bb2ca2" class="">where</font><span class="Apple-converted-space">&nbsp;</span><span class="" style="color: rgb(79, 129, 135);">shade</span><span class="Apple-converted-space">&nbsp;</span><span class="" style="color: rgb(49, 89, 93);">==</span><font color="#bb2ca2" class=""><span class="Apple-converted-space">&nbsp;</span>.</font><span class="" style="color: rgb(49, 89, 93);">Dark</span><font color="#bb2ca2" class="">:<span class="Apple-converted-space">&nbsp;</span></font><span class="" style="color: rgb(79, 129, 135);">res</span><font color="#bb2ca2" class=""><span class="Apple-converted-space">&nbsp;</span>=<span class="Apple-converted-space">&nbsp;</span></font><span class="" style="color: rgb(39, 42, 216);">0xFF1010</span></div><div class="" style="font-family: Menlo; margin: 0px; line-height: normal;"><span class="" style="color: rgb(187, 44, 162);">&nbsp; &nbsp; case .</span>Red<font color="#bb2ca2" class="">:<span class="Apple-converted-space">&nbsp;</span></font><span class="" style="color: rgb(79, 129, 135);">res</span><font color="#bb2ca2" class=""><span class="Apple-converted-space">&nbsp;</span>=<span class="Apple-converted-space">&nbsp;</span></font><span class="" style="color: rgb(39, 42, 216);">0xFF0000</span></div><div class="" style="font-family: Menlo; margin: 0px; line-height: normal;"><span class="" style="color: rgb(187, 44, 162);">&nbsp; &nbsp; case .</span>Green<font color="#bb2ca2" class="">:<span class="Apple-converted-space">&nbsp;</span></font><span class="" style="color: rgb(79, 129, 135);">res</span><font color="#bb2ca2" class=""><span class="Apple-converted-space">&nbsp;</span>=&nbsp;</font><span class="" style="color: rgb(39, 42, 216);">0x00FF00</span></div><div class="" style="font-family: Menlo; margin: 0px; line-height: normal;"><span class="" style="color: rgb(187, 44, 162);">&nbsp; &nbsp; case .</span>Blue<font color="#bb2ca2" class="">:<span class="Apple-converted-space">&nbsp;</span></font><span class="" style="color: rgb(79, 129, 135);">res</span><font color="#bb2ca2" class=""><span class="Apple-converted-space">&nbsp;</span>=<span class="Apple-converted-space">&nbsp;</span></font><span class="" style="color: rgb(39, 42, 216);">0x0000FF</span></div><div class="" style="font-family: Menlo; color: rgb(187, 44, 162); margin: 0px; line-height: normal;"><span class="">&nbsp; &nbsp;<span class="Apple-converted-space">&nbsp;</span></span>default<span class="">:</span></div><div class="" style="font-family: Menlo; color: rgb(187, 44, 162); margin: 0px; line-height: normal;">&nbsp; &nbsp; &nbsp; &nbsp;<span class="Apple-converted-space">&nbsp;</span><span class="" style="color: rgb(79, 129, 135);">res</span><span class="Apple-converted-space">&nbsp;</span>=<span class="Apple-converted-space">&nbsp;</span><span class="" style="color: rgb(39, 42, 216);">0xFFFFFF</span></div><div class="" style="font-family: Menlo; color: rgb(187, 44, 162); margin: 0px; line-height: normal;">}</div><div class="" style="color: rgb(187, 44, 162); margin: 0px; line-height: normal;"><div class="" style="font-family: Menlo; margin: 0px; line-height: normal;"><br class=""></div><div class="" style="margin: 0px; line-height: normal;">This one way to do the same thing with multiline and the expression if it makes it clearer, some may prefer this:&nbsp;</div><div class="" style="font-family: Menlo;"><br class=""></div></div><div class=""><div class="" style="font-family: Menlo; margin: 0px; line-height: normal;"><font color="#bb2ca2" class="">let&nbsp;</font>res = #(<span class="" style="color: rgb(79, 129, 135);">color&nbsp;</span>--&nbsp;</div><div class="" style="font-family: Menlo; margin: 0px; line-height: normal;"><font color="#bb2ca2" class="">&nbsp; &nbsp;&nbsp;case&nbsp;.</font>Red<font color="#bb2ca2" class="">&nbsp;where&nbsp;</font><span class="" style="color: rgb(79, 129, 135);">shade</span><font color="#bb2ca2" class="">&nbsp;</font><span class="" style="color: rgb(49, 89, 93);">==</span><font color="#bb2ca2" class="">&nbsp;.</font><span class="" style="color: rgb(49, 89, 93);">Dark</span><font color="#bb2ca2" class="">:&nbsp;</font><span class="" style="color: rgb(39, 42, 216);">0xFF1010</span></div><div class="" style="font-family: Menlo; margin: 0px; line-height: normal;"><span class="" style="color: rgb(187, 44, 162);">&nbsp; &nbsp;&nbsp;case&nbsp;.</span>Red<font color="#bb2ca2" class="">:&nbsp;</font><span class="" style="color: rgb(39, 42, 216);">0xFF0000</span></div><div class="" style="font-family: Menlo; margin: 0px; line-height: normal;"><span class="" style="color: rgb(187, 44, 162);">&nbsp; &nbsp;&nbsp;case&nbsp;.</span>Green<font color="#bb2ca2" class="">:&nbsp;</font><span class="" style="color: rgb(39, 42, 216);">0x00FF00</span></div><div class="" style="font-family: Menlo; margin: 0px; line-height: normal;"><span class="" style="color: rgb(187, 44, 162);">&nbsp; &nbsp; case .</span>Blue<font color="#bb2ca2" class="">:&nbsp;</font><span class="" style="color: rgb(39, 42, 216);">0x0000FF</span></div><div class="" style="font-family: Menlo; color: rgb(187, 44, 162); margin: 0px; line-height: normal;"><span class="">&nbsp; &nbsp;&nbsp;</span>default:&nbsp;<span class="" style="color: rgb(39, 42, 216);">0xFFFFFF</span></div><div class="" style="font-family: Menlo; color: rgb(187, 44, 162); margin: 0px; line-height: normal;">}</div><div class="" style="font-family: Menlo; color: rgb(187, 44, 162); margin: 0px; line-height: normal;"><br class=""></div><div class="" style="color: rgb(187, 44, 162); margin: 0px; line-height: normal;"><div class="" style="margin: 0px; line-height: normal;">Since this the case does not add anything, you can do this as well:</div><div class="" style="font-family: Menlo;"><br class=""></div></div></div><div class="" style="font-family: Menlo;"><div class="" style="margin: 0px; line-height: normal;"><font color="#bb2ca2" class="">let<span class="Apple-converted-space">&nbsp;</span></font>res = #(<span class="" style="color: rgb(79, 129, 135);">color<span class="Apple-converted-space">&nbsp;</span></span>—- &nbsp;<span class="" style="color: rgb(187, 44, 162);">.</span>Red<span class="Apple-converted-space">&nbsp;</span><font color="#bb2ca2" class="">where</font><span class="Apple-converted-space">&nbsp;</span><span class="" style="color: rgb(79, 129, 135);">shade</span><span class="Apple-converted-space">&nbsp;</span><span class="" style="color: rgb(49, 89, 93);">==</span><font color="#bb2ca2" class=""><span class="Apple-converted-space">&nbsp;</span>.</font><span class="" style="color: rgb(49, 89, 93);">Dark</span><font color="#bb2ca2" class="">:&nbsp;</font><span class="" style="color: rgb(39, 42, 216);">0xFF1010</span></div></div></div></div><blockquote class="" style="margin: 0px 0px 0px 40px; border: none; padding: 0px;"><blockquote class="" style="margin: 0px 0px 0px 40px; border: none; padding: 0px;"><blockquote class="" style="margin: 0px 0px 0px 40px; border: none; padding: 0px;"><div class="" style="margin: 0px; line-height: normal;"><div class="" style="margin: 0px; line-height: normal;"><div class="" style="font-family: Menlo;"><div class="" style="margin: 0px; line-height: normal;"><span class="" style="color: rgb(187, 44, 162);">&nbsp; &nbsp; &nbsp;.</span>Red<font color="#bb2ca2" class="">: &nbsp;&nbsp;</font><span class="" style="color: rgb(39, 42, 216);">0xFF0000</span></div></div></div></div></blockquote></blockquote><blockquote class="" style="margin: 0px 0px 0px 40px; border: none; padding: 0px;"><blockquote class="" style="margin: 0px 0px 0px 40px; border: none; padding: 0px;"><div class="" style="margin: 0px; line-height: normal;"><div class="" style="margin: 0px; line-height: normal;"><div class="" style="font-family: Menlo;"><div class="" style="margin: 0px; line-height: normal;"><span class="" style="color: rgb(187, 44, 162);">&nbsp; &nbsp; &nbsp;.</span>Green<font color="#bb2ca2" class="">:&nbsp;</font><span class="" style="color: rgb(39, 42, 216);">0x00FF00</span></div></div></div></div></blockquote></blockquote><blockquote class="" style="margin: 0px 0px 0px 40px; border: none; padding: 0px;"><blockquote class="" style="margin: 0px 0px 0px 40px; border: none; padding: 0px;"><div class="" style="margin: 0px; line-height: normal;"><div class="" style="margin: 0px; line-height: normal;"><div class="" style="font-family: Menlo;"><div class="" style="margin: 0px; line-height: normal;"><span class="" style="color: rgb(187, 44, 162);">&nbsp; &nbsp;&nbsp; .</span>Blue<font color="#bb2ca2" class="">:&nbsp;&nbsp;</font><span class="" style="color: rgb(39, 42, 216);">0x0000FF</span></div></div></div></div></blockquote></blockquote><blockquote class="" style="margin: 0px 0px 0px 40px; border: none; padding: 0px;"><blockquote class="" style="margin: 0px 0px 0px 40px; border: none; padding: 0px;"><div class="" style="margin: 0px; line-height: normal;"><div class="" style="margin: 0px; line-height: normal;"><div class="" style="font-family: Menlo;"><div class="" style="margin: 0px; line-height: normal;"><span class="">&nbsp; &nbsp; &nbsp;|</span><font color="#bb2ca2" class="">&nbsp;</font><span class="" style="color: rgb(39, 42, 216);">0xFFFFFF</span><span class="" style="color: rgb(187, 44, 162);">}</span></div></div></div></div></blockquote></blockquote></blockquote><div class="" style="margin: 0px; line-height: normal;"><div class="" style="margin: 0px; line-height: normal;"><div class="" style="font-family: Menlo; color: rgb(187, 44, 162);"><br class=""></div></div></div><div class="">If “case” makes the “where" clearer then I am fine requiring it but I don’t think it is necessary:<font face="Menlo" class="">&nbsp;</font>To make this kind of formatting easy, the editor should help align &nbsp;with the dashes. To allow more space on each line this would also work:</div><div class=""><br class=""></div><div class=""><div class="" style="margin: 0px; line-height: normal;"><div class="" style="margin: 0px; line-height: normal;"><div class="" style="font-family: Menlo;"><div class="" style="margin: 0px; line-height: normal;"><font color="#bb2ca2" class="">let&nbsp;</font>res = #(<span class="" style="color: rgb(79, 129, 135);">color</span></div><div class="" style="margin: 0px; line-height: normal;"><font color="#4f8187" class="">&nbsp; &nbsp; -</font>— &nbsp;&nbsp;<span class="" style="color: rgb(187, 44, 162);">.</span>Red&nbsp;<font color="#bb2ca2" class="">where</font>&nbsp;<span class="" style="color: rgb(79, 129, 135);">shade</span>&nbsp;<span class="" style="color: rgb(49, 89, 93);">==</span><font color="#bb2ca2" class="">&nbsp;.</font><span class="" style="color: rgb(49, 89, 93);">Dark</span><font color="#bb2ca2" class="">:&nbsp;</font><span class="" style="color: rgb(39, 42, 216);">0xFF1010</span></div><div class="" style="margin: 0px; line-height: normal;"><span class="" style="color: rgb(187, 44, 162);">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;.</span>Red<font color="#bb2ca2" class="">: &nbsp;&nbsp;</font><span class="" style="color: rgb(39, 42, 216);">0xFF0000</span></div><div class="" style="margin: 0px; line-height: normal;"><font color="#272ad8" class="">&nbsp; &nbsp;&nbsp;</font><span class="" style="color: rgb(187, 44, 162);"><span class="Apple-converted-space">&nbsp;</span>&nbsp; &nbsp; .</span>Green<font color="#bb2ca2" class="">:&nbsp;</font><span class="" style="color: rgb(39, 42, 216);">0x00FF00</span></div><div class="" style="margin: 0px; line-height: normal;"><font color="#272ad8" class="">&nbsp; &nbsp;&nbsp;</font><span class="" style="color: rgb(187, 44, 162);"><span class="Apple-converted-space">&nbsp;</span>&nbsp; &nbsp; .</span>Blue<font color="#bb2ca2" class="">: &nbsp;</font><span class="" style="color: rgb(39, 42, 216);">0x0000FF</span></div><div class="" style="margin: 0px; line-height: normal;"><font color="#272ad8" class="">&nbsp; &nbsp;&nbsp;</font><span class="Apple-converted-space">&nbsp;</span>&nbsp; &nbsp; |<font color="#bb2ca2" class="">&nbsp;</font><span class="" style="color: rgb(39, 42, 216);">0xFFFFFF</span><span class="" style="color: rgb(187, 44, 162);">}</span></div></div></div></div><div class="" style="margin: 0px; line-height: normal;"><div class="" style="margin: 0px; line-height: normal;"></div></div></div><div class=""><br class=""></div><div class="">one last option for maximum space on the line:</div><div class=""><br class=""></div><div class=""><div class=""><div class="" style="margin: 0px; line-height: normal;"><div class="" style="margin: 0px; line-height: normal;"><div class=""><div class="" style="font-family: Menlo; margin: 0px; line-height: normal;"><font color="#bb2ca2" class="">let&nbsp;</font>res = #(<span class="" style="color: rgb(79, 129, 135);">color&nbsp;</span>—-&nbsp;</div><div class="" style="font-family: Menlo; margin: 0px; line-height: normal;">&nbsp;<span class="" style="color: rgb(187, 44, 162);">.</span>Red&nbsp;<font color="#bb2ca2" class="">where</font>&nbsp;<span class="" style="color: rgb(79, 129, 135);">shade</span>&nbsp;<span class="" style="color: rgb(49, 89, 93);">==</span><font color="#bb2ca2" class="">&nbsp;.</font><span class="" style="color: rgb(49, 89, 93);">Dark</span><font color="#bb2ca2" class="">:&nbsp;</font><span class="" style="color: rgb(39, 42, 216);">0xFF1010</span></div><div class="" style="font-family: Menlo; margin: 0px; line-height: normal;"><span class="" style="color: rgb(187, 44, 162);">&nbsp;.</span>Red<font color="#bb2ca2" class="">: &nbsp;&nbsp;</font><span class="" style="color: rgb(39, 42, 216);">0xFF0000</span></div><div class="" style="font-family: Menlo; margin: 0px; line-height: normal;"><font color="#272ad8" class="">&nbsp;</font><span class="" style="color: rgb(187, 44, 162);">.</span>Green<font color="#bb2ca2" class="">:&nbsp;</font><span class="" style="color: rgb(39, 42, 216);">0x00FF00</span></div><div class="" style="font-family: Menlo; margin: 0px; line-height: normal;"><font color="#272ad8" class="">&nbsp;</font><span class="" style="color: rgb(187, 44, 162);">.</span>Blue<font color="#bb2ca2" class="">: &nbsp;</font><span class="" style="color: rgb(39, 42, 216);">0x0000FF</span></div><div class="" style="font-family: Menlo; margin: 0px; line-height: normal;"><font color="#272ad8" class="">&nbsp;</font>|<font color="#bb2ca2" class="">&nbsp;</font><span class="" style="color: rgb(39, 42, 216);">0xFFFFFF</span><span class="" style="color: rgb(187, 44, 162);">}</span></div><div class="" style="font-family: Menlo; margin: 0px; line-height: normal;"><br class=""></div></div></div></div></div><blockquote type="cite" class=""><div class="">On Dec 23, 2015, at 11:51 AM, Paul Ossenbruggen &lt;<a href="mailto:possen@gmail.com" class="">possen@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Been thinking about the boolean case a bit more, and how to make it better than a ternary using my proposed syntax. So else could be put there to help show it is the opposite. The downside is this makes it mix keywords and operators so seems a bit jarring.&nbsp;<div class=""><br class=""></div><div class=""><p class="" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);">With the new form parenthesis are built into it and are required:</p><div class="highlight highlight-source-swift" style="box-sizing: border-box; margin-bottom: 16px; color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);"><pre class="" style="box-sizing: border-box; overflow: auto; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; margin-top: 0px; margin-bottom: 0px; line-height: 1.45; padding: 16px; background-color: rgb(247, 247, 247); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: normal; word-break: normal;">x <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> ?(x <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">==</span> y <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">:</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">49</span> <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">else</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">3</span>) </pre></div><p class="" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);">alternatively the bang means do the opposite:</p><div class="highlight highlight-source-swift" style="box-sizing: border-box; margin-bottom: 16px; color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);"><pre class="" style="box-sizing: border-box; overflow: auto; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; margin-top: 0px; margin-bottom: 0px; line-height: 1.45; padding: 16px; background-color: rgb(247, 247, 247); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: normal; word-break: normal;">x <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> ?(x <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">==</span> y <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">:</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">49</span> <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">!</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">3</span>) <span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">// not sure this creates a parsing problem. </span></pre></div><p class="" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);">or if the above causes a parsing problem:</p><div class="highlight highlight-source-swift" style="box-sizing: border-box; margin-bottom: 16px; color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);"><pre class="" style="box-sizing: border-box; overflow: auto; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; margin-top: 0px; margin-bottom: 0px; line-height: 1.45; padding: 16px; background-color: rgb(247, 247, 247); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: normal; word-break: normal;">x <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> ?(x <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">==</span> y <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">:</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">49</span> <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">|</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">3</span>)  </pre></div><div class="">Any thoughts?</div><div class=""><br class=""></div><div class=""><blockquote type="cite" class=""><div class="">On Dec 23, 2015, at 7:02 AM, Félix Cloutier via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><span class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;">I know, but that won't support pattern matching.</span><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br class=""><div class=""><span class="Apple-style-span" style="border-collapse: separate; font-family: 'Lucida Grande'; line-height: normal; border-spacing: 0px;">Félix</span></div><br class=""><div class=""><blockquote type="cite" class=""><div class="">Le 23 déc. 2015 à 02:22:07, David Waite &lt;<a href="mailto:david@alkaline-solutions.com" class="">david@alkaline-solutions.com</a>&gt; a écrit :</div><br class="Apple-interchange-newline"><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">In the case where your input is hashable, you could just do:<div class=""><br class=""></div><div class=""><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(39, 42, 216);"><span class="" style="color: rgb(187, 44, 162);">let</span><span class="">&nbsp;i = [.</span><span class="" style="color: rgb(49, 89, 93);">Red</span><span class="">:</span>0xff0000<span class="">, .</span><span class="" style="color: rgb(49, 89, 93);">Green</span><span class="">:</span>0x00ff00<span class="">, .</span><span class="" style="color: rgb(49, 89, 93);">Blue</span><span class="">:</span>0x0000ff<span class="">][</span><span class="" style="color: rgb(79, 129, 135);">color</span><span class="">]</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(39, 42, 216);"><span class=""><br class=""></span></div><div class="" style="margin: 0px; line-height: normal;"><font face="Menlo" class=""><span class="" style="font-size: 11px;">this would mean that color must be a Color and not an Optional&lt;Color&gt; (because of swift 2.x limitations)</span></font></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(39, 42, 216);"><span class=""><br class=""></span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(39, 42, 216);"><span class="">-DW</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(39, 42, 216);"><span class=""><br class=""></span></div><div class=""><blockquote type="cite" class=""><div class="">On Dec 22, 2015, at 8:04 AM, Félix Cloutier via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">I like the gist of it too, though you seem to introduce both a new keyword and a new syntax. (To be clear, I like the syntax but I'm ambivalent towards reusing switch instead of which.)<br class=""><br class="">My minor suggestions would to avoid braces for things that aren't scopes; that either the comma or the the question mark is redundant in their current position (you need a start delimiter or an end delimiter but you don't need both); and that it needs a way to handle a default case if enumeration isn't exhaustive (I'd do that by returning an optional).<br class=""><br class=""><blockquote type="cite" class="">let i = which color (.Red: 0xff0000, .Green: 0x00ff00, .Blue: 0x0000ff) ?? 0x000000<br class=""></blockquote><br class=""><br class="">Thinking out loud, once you remove the question marks it really looks like a dictionary literal, so maybe it could even use square brackets to close the gap.<br class=""><br class=""><blockquote type="cite" class="">let i = which color [.Red: 0xff0000, .Green: 0x00ff00, .Blue: 0x0000ff] ?? 0x000000<br class=""></blockquote><br class=""><br class="">I thought about subscripting a dictionary literal in place:<br class=""><br class=""><blockquote type="cite" class="">[Color.Red: 0xff0000, ...][color] ?? 0x000000<br class=""></blockquote><br class=""><br class="">but that won't support elaborate pattern matching, and I think that this is a deal breaker for the functional folks.<br class=""><br class="">Félix<br class=""><br class=""><blockquote type="cite" class="">Le 22 déc. 2015 à 09:31:32, Charles Constant &lt;<a href="mailto:charles@charlesism.com" class="">charles@charlesism.com</a>&gt; a écrit :<br class=""><br class="">Just goofing on this a little. What if we called it a "which" statement, instead of a "switch" statement? It's a bit cutesy, but not too verbose, and it makes sense if you read it aloud.<br class=""><br class="">let i = which color {<br class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>? .Red: 0xFF0000,<span class="Apple-converted-space">&nbsp;</span><br class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>? .Green: 0x00FF00,<span class="Apple-converted-space">&nbsp;</span><br class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>? .Blue: 0x00000FF<br class="">}<br class=""><br class="">let i = which boo {<br class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>? true: 1,<span class="Apple-converted-space">&nbsp;</span><br class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>? false: 0,<span class="Apple-converted-space">&nbsp;</span><br class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>? nil: -1<br class="">}<br class=""><br class=""></blockquote><br class="">_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div></div></blockquote></div><br class=""></div></div></div></blockquote></div><br class=""></div><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=emrIhnP1hIf76Foxxv4NNJQX-2FWhcznESwKBSwD1MEwyE0wTxxNECMPPCzo-2FHTW73rbbjXg-2BkDsDXavGQRCH-2BQ3MVHuZZpqgJplv86uUZoGsXw4QiMMSHM7Rd5jhg7ISmdEVPAPcJGXs7M4iyRFt8uZ-2FU9A47RmlVFvFti5ZfpkwXHXu-2FstKfyhK3bAm7-2FBt9PJckFHcYKDhCLL-2FdK6cCrvhygEw9ZWe7EDng6hzlirg-3D" alt="" width="1" height="1" border="0" class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; height: 1px !important; width: 1px !important; border-width: 0px !important; margin: 0px !important; padding: 0px !important;"><span class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;"><span class="Apple-converted-space">&nbsp;</span></span><span class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;">_______________________________________________</span><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;">swift-evolution mailing list</span><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><a href="mailto:swift-evolution@swift.org" class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">swift-evolution@swift.org</a><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">https://lists.swift.org/mailman/listinfo/swift-evolution</a></div></blockquote></div><br class=""></div></div></div></blockquote></div><br class=""></div></div></blockquote></div><br class=""></div></div></div><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=Vm9j-2B2K6zLqxUFTO82XA8HV2TThDz5lA3-2F-2Fpeujw7DQEkp9mjyzfHAR4XgPFuHN2XaRHLRZW1wbv6LZQrFqjZJlLbSGf68eHT7iZYNk96tuSUvWNbb8w54JUZWrNiRQEC5LOtkR1g-2FQhP75yLKKU3tcapTgX3SQASR0yBPpBDSjT-2BeKMiZVO930f6F-2FXOs0TSngU8AAn-2Fh0boBjEKdW3LSIwNU3FDCSu1DeM7wQj5bU-3D" alt="" width="1" height="1" border="0" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; height: 1px !important; width: 1px !important; border-width: 0px !important; margin: 0px !important; padding: 0px !important;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class=""><span class="Apple-converted-space">&nbsp;</span></span><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">_______________________________________________</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">swift-evolution mailing list</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="mailto:swift-evolution@swift.org" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">swift-evolution@swift.org</a><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></div></blockquote></div><br class=""></div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=a745LmqnDfg8U5xkzxO94fzXSZ0ZB2d7MXjmVBHs4IEqFPgVTbqmkTi4uyiN-2FN0rnTRWDzr29rgvMQn664L5tFOomZlTTa646rMbxU-2BrZuD8u5byvxxSHivBZ0K0PmeGoGAsbZU7B-2FJl6mmqdapwX1v3C3qAwwO0PzLvR9-2FAdKIWK0LMAmxgruY4eBTOCrDvA-2BdyHUSCS-2F4AJ1MKe0IDuTGkvfLu6b-2FNS5ViSNOfpxM-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;" class="">

</div></blockquote><blockquote type="cite" class=""><div class=""><span class="">_______________________________________________</span><br class=""><span class="">swift-evolution mailing list</span><br class=""><span class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a></span><br class=""><span class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br class=""></div></blockquote></div></div></blockquote></div><br class=""></div></body></html>