<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div></div><div>While it is real nice what can be done with a library solution, the switch-expression allows more than just comparing with a value. Library solutions won't be able to achieve the following features:</div><div><br></div><div>- pattern matching</div><div>- where clauses</div><div>- exhaustiveness check</div><div><br></div><div>-Thorsten </div><div><br>Am 05.01.2016 um 18:10 schrieb Jo Albright via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>>:<br><br></div><blockquote type="cite"><div><meta http-equiv="Content-Type" content="text/html charset=utf-8">I am really enjoying this conversation. I think the ternary switch is useful for advanced one line case values. I have been playing to see what can currently be done. Attached is a playground for those who want to see results… the range case takes a second to run. I know there can be optimizations done, but just wanted to add my thoughts to the conversation. <div class=""><br class=""></div><div class="">Chose ??? to denote a ternary switch, to be inline with ? = ternary, ?? = nil coalescing … the other two operators where just placeholders. I don’t believe || is a great solution as it is a comparison operator and —> is confusing and resembles return… but again, nothing serious... just playing with playground (indulging my current obsession with custom operators).</div><div class=""><br class=""></div><div class="">With the below, I <b class="">don’t</b> feel there is a huge need to change the language… unless incorporating the actual switch optimization is worth it.</div><div class=""><br class=""></div><div class=""><div class="">Thanks,</div><div class="">Jo Albright<br class=""><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class="">// ??? loops array and returns first element where lhs == element.0</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(187, 44, 162);" class="">infix<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span>operator<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> ??? { </span>associativity<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> left </span>precedence<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">200</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> }</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class="">// || merges values into an array</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(187, 44, 162);" class="">infix<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span>operator<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> || { </span>associativity<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> left </span>precedence<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">210</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> }</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class="">// --> convert lhs & rhs to tuple (lhs,rhs)</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(187, 44, 162);" class="">infix<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span>operator<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> --> { </span>associativity<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> left </span>precedence<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">220</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> }</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">func</span> ??? <T: <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Equatable</span>>(lhs: <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">T</span>?, rhs: [(<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">T</span>,<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">AnyObject</span>)]) -> <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">AnyObject</span>? {</div><p style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""> <br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">for</span> r <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">in</span> rhs { <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">if</span> lhs == r.<span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">0</span> { <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">return</span> r.<span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">1</span> } }; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">return</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">nil</span></div><p style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""> <br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">}</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">func</span> ??? <T: <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Equatable</span>>(lhs: <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">T</span>, rhs: [(<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">T</span>,<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">AnyObject</span>)]) -> <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">AnyObject</span>? {</div><p style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""> <br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">for</span> r <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">in</span> rhs { <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">if</span> lhs <span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">==</span> r.<span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">0</span> { <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">return</span> r.<span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">1</span> } }; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">return</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">nil</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">}</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">func</span> || <T>(lhs: (<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">T</span>,<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">AnyObject</span>), rhs: (<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">T</span>,<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">AnyObject</span>)) -> [(<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">T</span>,<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">AnyObject</span>)] {</div><p style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""> <br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">return</span> [lhs,rhs]</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">}</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">func</span> || <T>(lhs: [(<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">T</span>,<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">AnyObject</span>)], rhs: (<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">T</span>,<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">AnyObject</span>)) -> [(<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">T</span>,<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">AnyObject</span>)] {</div><p style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""> <br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">return</span> lhs + [rhs]</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">}</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">func</span> || <T>(lhs: (<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Range</span><<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">T</span>>,<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">AnyObject</span>), rhs: (<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Range</span><<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">T</span>>,<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">AnyObject</span>)) -> [(<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">T</span>,<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">AnyObject</span>)] {</div><p style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""> <br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">return</span> lhs.<span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">0</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">map</span> { ($0,lhs.<span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">1</span>) } + rhs.<span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">0</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">map</span> { ($0,rhs.<span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">1</span>) }</div><p style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""> <br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">}</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">func</span> || <T>(lhs: (<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Range</span><<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">T</span>>,<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">AnyObject</span>), rhs: (<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">T</span>,<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">AnyObject</span>)) -> [(<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">T</span>,<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">AnyObject</span>)] {</div><p style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""> <br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">return</span> lhs.<span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">0</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">map</span> { ($0,lhs.<span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">1</span>) } + [rhs]</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">}</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">func</span> || <T>(lhs: [(<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">T</span>,<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">AnyObject</span>)], rhs: (<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Range</span><<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">T</span>>,<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">AnyObject</span>)) -> [(<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">T</span>,<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">AnyObject</span>)] {</div><p style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""> <br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">return</span> lhs + rhs.<span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">0</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">map</span> { ($0,rhs.<span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">1</span>) }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">}</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">func</span> --> <T>(lhs: <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">T</span>, rhs: <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">AnyObject</span>) -> (<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">T</span>,<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">AnyObject</span>) {</div><p style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""> <br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">return</span> (lhs,rhs)</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">}</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">enum</span> LifeStatus { <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">case</span> Alive, Dead, Zombie }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span> life: <span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">LifeStatus</span>? = .<span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">Dead</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class="">// embedded ternary operators … how I have built a ternary switch in past</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span> color1 = <span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">life</span> == .<span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">Alive</span> ? <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">UIColor</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">greenColor</span>() : <span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">life</span> == .<span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">Dead</span> ? <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">UIColor</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">redColor</span>() : <span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">life</span> == .<span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">Zombie</span> ? <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">UIColor</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">grayColor</span>() : <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">UIColor</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">whiteColor</span>()</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class="">// using custom operators</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span> color2 = <span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">life</span> <span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">???</span> .<span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">Alive</span> <span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">--></span> <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">UIColor</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">greenColor</span>() <span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">||</span> .<span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">Dead</span> <span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">--></span> <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">UIColor</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">redColor</span>() <span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">||</span> .<span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">Zombie</span> <span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">--></span> <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">UIColor</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">grayColor</span>() ?? <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">UIColor</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">whiteColor</span>()</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span> age = <span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">15</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class="">// works with ranges</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span> ageGroup = <span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">age</span> <span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">???</span> (<span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">0</span>...<span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">1</span>) <span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">--></span> <span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">"baby"</span> <span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">||</span> (<span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">2</span>...<span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">4</span>) <span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">--></span> <span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">"toddler"</span> <span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">||</span> (<span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">5</span>...<span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">12</span>) <span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">--></span> <span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">"kid"</span> <span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">||</span> (<span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">13</span>...<span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">19</span>) <span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">--></span> <span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">"teen"</span> ?? <span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">"adult"</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class=""><span style="color: rgb(79, 129, 135);" class="">ageGroup</span> //<font color="#008400" face="Menlo" class=""> “teen”</font></div></div><div class=""><br class=""></div><div class=""><br class=""><div class=""></div></div></div></div></div></blockquote><blockquote type="cite"><div><TernarySwitch.playground.zip></div></blockquote><blockquote type="cite"><div><meta http-equiv="Content-Type" content="text/html charset=us-ascii"><div class=""><div class=""><div class=""><div class=""></div></div></div></div></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>