<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=""><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 16, 2015, at 2:56 PM, Paul Ossenbruggen via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><div class=""><b class="">Selector Operator Proposal</b></div><div class=""><br class=""></div><div class="">OK really trying to get this down to its essence, make something that is truly better and more powerful than ternary, and try to keep as much of the advantages of the ternary and hopefully slightly improve the readability. I am calling it the "selector operator". This proposal, does not add a new keyword but adds a new operator. It unifies the concepts of ternary and gives us a new switch like behavior that ternary does not support. The concept is kind of like a train track, with multiple possible directions selectable by one input. </div><div class=""><br class=""></div><div class="">I believe it also addresses the issues that Chris mentioned. </div><div class=""><br class=""></div><div class="">to select from a boolean, a or b:</div><div class=""><font face="Monaco" class="">let a = sel ->> true, false</font></div></div></div></div></blockquote><div><br class=""></div><div>I’m not sure how I feel about this proposal in general, but if you changed the RHS to take a tuple, you could define it entirely in the library as a binary operator, instead of hacking it into the compiler, like ?: is.</div><div><br class=""></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>let a = sel ->> (true, false)</div><div><br class=""></div><div>The primary disadvantage of this (which is probably a showstopper!) is that you lose short circuiting.</div><div><br class=""></div><div>-Chris</div></div></body></html>