<div dir="ltr">Hi John,<div><br></div><div>I realize the Swift philosophy is puposefully against brevity at the expense of clarity, but to my eye a switch - for the task we're discussing is verbose enough to be more confusing. </div><div><br></div><div>**** Proposal ****</div><div><br></div><div><span class="" style="white-space:pre">         </span>let val = color ? ( .Red ! 0xFF0000 ) : ( .Green ! 0x00FF00 ) : ( .Blue ! 0x0000FF ) : ( _ ! 0xFFFFFF )<br></div><div><br></div><div>**** Existing ****</div><div><br></div><div><span class="" style="white-space:pre">        let val:Int</span><br></div><div><span class="" style="white-space:pre"><br></span></div><div><span class=""><p style="white-space:pre;margin:0px;font-size:13px;line-height:normal;font-family:Arial;min-height:15px"><span class="">        switch color {</span></p><p style="margin:0px;line-height:normal;min-height:15px"><font face="Arial"><span style="white-space:pre">                case .Red: </span></font><span style="white-space:pre">val = </span><span style="white-space:pre">0xFF0000</span></p><p style="margin:0px;line-height:normal;min-height:15px"><font face="Arial"><span style="white-space:pre">                case .Green</span></font><font face="Arial"><span style="white-space:pre">: </span></font><span style="white-space:pre">val = </span><span style="white-space:pre">0x00FF00</span></p><p style="margin:0px;line-height:normal;min-height:15px"><font face="Arial"><span style="white-space:pre">                case .Blue: </span></font><span style="font-family:arial,sans-serif;font-size:small;white-space:pre">val = </span><span style="white-space:pre">0x0000FF</span><br></p><p style="margin:0px;line-height:normal;min-height:15px"><font face="Arial"><span style="white-space:pre">                default: </span></font><span style="font-family:arial,sans-serif;font-size:small;white-space:pre">val = </span><span style="white-space:pre">0xFFFFFF</span><br></p><p style="white-space:pre;margin:0px;font-size:13px;line-height:normal;font-family:Arial;min-height:15px"><span class="">        </span>}<br></p></span></div><div><span class="" style="white-space:pre"><br></span></div><div><span class="" style="white-space:pre"><span style="white-space:normal">****</span><br></span></div><div><span class="" style="white-space:pre"><span style="white-space:normal"><br></span></span></div><div><span class="">If I'm revisiting my code, I'd prefer to reread the short version. It's not just easier to write, but also probably easier to read. Of course, there's no empirical evidence unless we sit down a bunch of programmers and do a study. So that's just my opinion.</span></div><div><span class="" style="white-space:pre"><br></span></div><div><span class="" style="white-space:pre"><br></span></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jan 6, 2016 at 6:07 AM, John Randolph <span dir="ltr"><<a href="mailto:jcr@icloud.com" target="_blank">jcr@icloud.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Really not a fan of the idea of bloating the ternary operator out to deal with more cases. That’s what we already have switch and enum for.<br>
<br>
-jcr</blockquote></div><br></div>