<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">There was a popular pattern which went as follows:<div class=""><br class=""></div><div class="">let myThing = {</div><div class="">&nbsp; if someCondition {</div><div class="">&nbsp; &nbsp; return 1</div><div class="">&nbsp; } else {</div><div class="">&nbsp; &nbsp; return 2</div><div class="">&nbsp; }</div><div class="">}()</div><div class=""><br class=""></div><div class="">It's a little ugly, but the compiler is apparently smart enough to inline/optimize away the anonymous closure. It became less popular once Swift got support for declaring lets without an initial value.</div><div class=""><br class=""></div><div class="">Austin</div><div class=""><br class=""></div><div><blockquote type="cite" class=""><div class="">On Jan 4, 2016, at 10:55 PM, Charles Constant 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 dir="ltr" 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=""><div class=""><span style="font-size: 13px;" class="">My best guesses here, since I didn't write and don't entirely agree...</span></div><div class=""><span style="font-size: 13px;" class=""><br class=""></span></div><div class=""><b class=""><span style="font-size: 13px;" class="">&gt;&nbsp;</span><span style="font-size: 13px;" class="">Please detail what the trade offs are</span></b></div><span style="font-size: 13px;" class=""><div class=""><span style="font-size: 13px;" class=""><br class=""></span></div><div class="">Other than more complexity, I think this refers to making the "switch" statement do two slightly different things. Of course, if we call it something else, like "match" or "which" then it stops being an issue.</div><div class=""><span style="font-size: 13px;" class=""><br class=""></span></div><b class="">&gt; What are the other ways that Swift currently supports this?</b></span><br class=""><div class=""><span style="font-size: 13px;" class=""><br class=""></span></div><div class="">As far as I can see, the closest we get are...</div><div class=""><br class=""></div><div class="">&nbsp; &nbsp; a) The existing "switch" statement, or if else statement (preceded with a statement to declare the variable. yuck). I think this is verbose enough to qualify as "confusing"</div><div class=""><br class=""></div><div class="">&nbsp; &nbsp; b) Creating an anonymous dict, and immediately accessing it (which means the keys need to be Hashable). This isn't very flexible</div><div class=""><br class=""></div><div class="">&nbsp; &nbsp; c) Creating a special init or function, to map one enum, to another. This &nbsp;is also verbose, and not flexible, and moves the code away from where it used (even if you never reuse the mapping).</div><div class=""><br class=""></div><div class="">&nbsp; &nbsp; d) Chaining a bunch of conditions in a ternary... Horrible.</div><div class=""><br class=""></div><div class="">Anyone know of any better alternatives? It feels like I'm missing something.</div><div class=""><br class=""></div></div></div></blockquote></div><br class=""></body></html>