<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=""><div class="">I certainly would prefer if we could use switch (and if/else for that matter) as an expression, instead of some magic syntax usable in `map`. so:</div><div class=""><br class=""></div><div class="">let str = switch(state) {</div>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;case&nbsp;.Cold:&nbsp;&nbsp;"Too cold"<br class="">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;case&nbsp;.Hot:&nbsp;&nbsp; &nbsp;"Too hot"<br class="">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;default: &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;"Just right"<br class="">&nbsp; &nbsp; }<div class=""><br class=""><div class=""><br class=""><div class="">
<div class="">— Radek</div>
</div>
<br class=""><div><blockquote type="cite" class=""><div class="">On 29 Jan 2016, at 08:10, Paul Cantrell 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=""><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=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Jan 29, 2016, at 1:01 AM, 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" class=""><div class="gmail_extra">I'm still +1 on this.</div><div class="gmail_extra"><br class=""></div><div class="gmail_extra">I would very much enjoy being able to do this:</div><div class="gmail_extra"><br class=""></div><div class="gmail_extra"><div style="margin-bottom: 16px; color: rgb(51, 51, 51); line-height: 25.6px;" class=""><pre style="white-space: pre-wrap; overflow: auto; margin-top: 0px; margin-bottom: 0px; line-height: 1.45; padding: 16px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: normal; background-color: rgb(247, 247, 247);" class=""><div style="margin: 0px; line-height: normal; color: rgb(167, 29, 93); min-height: 16px;" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class=""><span class="">let</span><span style="color: rgb(50, 51, 51);" class=""> str = state.</span><span class="">map</span><span style="color: rgb(50, 51, 51);" class=""> {</span><br class=""></span></font></div><div style="margin: 0px; line-height: normal; color: rgb(50, 51, 51);" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class=""><span class="" style="white-space:pre">        </span><span style="color:rgb(167,29,93)" class="">case</span> <span style="color:rgb(167,29,93)" class="">.</span>Cold: <span class="" style="white-space:pre">        </span>“Too cold”</span></font></div><div style="margin: 0px; line-height: normal; color: rgb(50, 51, 51);" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class=""><span style="color:rgb(167,29,93)" class=""><span class="" style="white-space:pre">        </span>case</span> <span style="color:rgb(167,29,93)" class="">.</span>Hot: <span class="" style="white-space:pre">        </span>“Too hot”</span></font></div><div style="margin: 0px; line-height: normal; color: rgb(50, 51, 51);" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class=""><span style="color:rgb(167,29,93)" class=""><span class="" style="white-space:pre">        </span>default</span>: <span class="" style="white-space:pre">        </span>“Just right”</span></font></div><div style="margin: 0px; line-height: normal; color: rgb(50, 51, 51);" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">}</span></font></div></pre></div></div></div></div></blockquote></div><div class=""><br class=""></div><div class="">The language currently allows this:</div><br class=""><div class=""><div style="margin: 0px; font-size: 10.5px; line-height: normal; font-family: Menlo;" class=""><div style="margin: 0px; font-size: 10.5px; line-height: normal;" class="">&nbsp; &nbsp;&nbsp;<span style="font-variant-ligatures: no-common-ligatures; color: #323e7d" class="">let</span> str: <span style="font-variant-ligatures: no-common-ligatures; color: #587ea8" class="">String</span></div><div style="margin: 0px; font-size: 10.5px; line-height: normal;" class="">&nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #323e7d" class="">switch</span>(<span style="font-variant-ligatures: no-common-ligatures; color: #587ea8" class="">state</span>) {</div><div style="margin: 0px; font-size: 10.5px; line-height: normal;" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #323e7d" class="">case</span> .Cold: <span style="font-variant-ligatures: no-common-ligatures; color: #587ea8" class="">str</span> = <span style="font-variant-ligatures: no-common-ligatures; color: #843e64" class="">"Too cold"</span></div><div style="margin: 0px; font-size: 10.5px; line-height: normal;" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #323e7d" class="">case</span> .Hot:&nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #587ea8" class="">str</span> = <span style="font-variant-ligatures: no-common-ligatures; color: #843e64" class="">"Too hot"</span></div><div style="margin: 0px; font-size: 10.5px; line-height: normal;" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #323e7d" class="">default</span>:&nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #587ea8" class="">str</span> = <span style="font-variant-ligatures: no-common-ligatures; color: #843e64" class="">"Just right"</span></div><div style="margin: 0px; font-size: 10.5px; line-height: normal;" class="">&nbsp; &nbsp; }</div><div class=""><br class=""></div></div></div><div class=""><div class="">While that’s slightly noisier, I’m not convinced the minor additional concision justifies the substantial additional language complexity. I’m not even convinced the new syntax is clearer so much as cleverer.</div><div class=""><br class=""></div><div class="">I’d need to see a much more compelling example to be in favor of this proposal.</div></div><div class=""><br class=""></div><div class="">Cheers,</div><div class=""><br class=""></div><div class="">Paul</div><div class=""><br class=""></div><div class=""><br class=""></div></div>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></div></div></body></html>