<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's a fairly subtle difference between `case Foo` and `case let Foo` when using a switch inside an enumeration. The first matches the Foo case of the current enumeration, the second binds a local `Foo` (that shadows .Foo) to any case. See the `testLet` property in this example:<div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">enum</span> Test {</div><div style="margin: 0px; line-height: normal;" class="">&nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">case</span> One, Two</div><p style="margin: 0px; line-height: normal; min-height: 13px;" class="">&nbsp;&nbsp; &nbsp;<br class="webkit-block-placeholder"></p><div style="margin: 0px; line-height: normal;" class="">&nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">var</span> testDot: <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">String</span> {</div><div style="margin: 0px; line-height: normal;" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">switch</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">self</span> {</div><div style="margin: 0px; line-height: normal;" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">case</span> .One: <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">return</span> <span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">"One"</span></div><div style="margin: 0px; line-height: normal;" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">case</span> .Two: <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">return</span> <span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">"Two"</span></div><div style="margin: 0px; line-height: normal;" class="">&nbsp; &nbsp; &nbsp; &nbsp; }</div><div style="margin: 0px; line-height: normal;" class="">&nbsp; &nbsp; }</div><p style="margin: 0px; line-height: normal; min-height: 13px;" class="">&nbsp;&nbsp; &nbsp;<br class="webkit-block-placeholder"></p><div style="margin: 0px; line-height: normal;" class="">&nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">var</span> testLetDot: <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">String</span> {</div><div style="margin: 0px; line-height: normal;" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">switch</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">self</span> {</div><div style="margin: 0px; line-height: normal;" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">case</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span> .One: <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">return</span> <span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">"One"</span></div><div style="margin: 0px; line-height: normal;" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">case</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span> .Two: <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">return</span> <span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">"Two"</span></div><div style="margin: 0px; line-height: normal;" class="">&nbsp; &nbsp; &nbsp; &nbsp; }</div><div style="margin: 0px; line-height: normal;" class="">&nbsp; &nbsp; }</div><p style="margin: 0px; line-height: normal; min-height: 13px;" class="">&nbsp;&nbsp; &nbsp;<br class="webkit-block-placeholder"></p><div style="margin: 0px; line-height: normal;" class="">&nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">var</span> testLet: <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">String</span> {</div><div style="margin: 0px; line-height: normal;" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">switch</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">self</span> {</div><div style="margin: 0px; line-height: normal; color: rgb(0, 132, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">case</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> One: </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">return</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">"One"&nbsp;</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span>// Danger Will Robinson</div><div style="margin: 0px; line-height: normal;" class="">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span style="color: rgb(187, 44, 162);" class="">case</span> <span style="color: rgb(187, 44, 162);" class="">let</span> Two: <span style="color: rgb(187, 44, 162);" class="">return</span> <span style="color: rgb(209, 47, 27);" class="">"Two"</span></div><div style="margin: 0px; line-height: normal;" class="">&nbsp; &nbsp; &nbsp; &nbsp; }</div><div style="margin: 0px; line-height: normal;" class="">&nbsp; &nbsp; }</div><p style="margin: 0px; line-height: normal; min-height: 13px;" class="">&nbsp;&nbsp; &nbsp;<br class="webkit-block-placeholder"></p><div style="margin: 0px; line-height: normal;" class="">&nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">var</span> testNone: <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">String</span> {</div><div style="margin: 0px; line-height: normal;" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">switch</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">self</span> {</div><div style="margin: 0px; line-height: normal;" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">case</span> One: <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">return</span> <span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">"One"</span></div><div style="margin: 0px; line-height: normal;" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">case</span> Two: <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">return</span> <span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">"Two"</span></div><div style="margin: 0px; line-height: normal;" class="">&nbsp; &nbsp; &nbsp; &nbsp; }</div><div style="margin: 0px; line-height: normal;" class="">&nbsp; &nbsp; }</div><div style="margin: 0px; line-height: normal;" class="">}</div><div style="margin: 0px; line-height: normal; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span> two = <span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">Test</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">Two</span></div><div style="margin: 0px; line-height: normal; color: rgb(79, 129, 135);" class="">two<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">.</span>testDot<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #008400" class="">// Two</span></div><div style="margin: 0px; line-height: normal; color: rgb(79, 129, 135);" class="">two<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">.</span>testLetDot<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">&nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #008400" class="">// Two</span></div><div style="margin: 0px; line-height: normal; color: rgb(79, 129, 135);" class="">two<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">.</span>testLet<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #008400" class="">// One</span></div><div style="margin: 0px; line-height: normal; color: rgb(79, 129, 135);" class="">two<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">.</span>testNone<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #008400" class="">// Two</span></div></div><div class=""><span style="font-variant-ligatures: no-common-ligatures; color: #008400" class=""><br class=""></span></div><div class=""><br class=""></div><div><blockquote type="cite" class=""><div class="">On Jan 15, 2016, at 6:42 PM, Joe Groff 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 class=""><br class=""><blockquote type="cite" class="">On Jan 15, 2016, at 2:44 PM, Jens Persson via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""><br class="">enum SomeEnum {<br class=""> &nbsp;&nbsp;&nbsp;case Foo<br class=""> &nbsp;&nbsp;&nbsp;case Bar<br class=""> &nbsp;&nbsp;&nbsp;func demoDotAndNoDot() {<br class=""> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;switch self {<br class=""> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case .Foo: print("This has the usual dot before the case name.")<br class=""> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case Bar: print("This has no dot, which is ok, at least in this particular context.")<br class=""> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br class=""> &nbsp;&nbsp;&nbsp;}<br class="">}<br class=""><br class="">I'm just throwing this out in case someone should feel like writing a formal proposal to remove the dotless form.<br class=""><br class="">I'd be ok with removing it since it only works in some specific contexts. <br class=""></blockquote><br class="">This works by normal instance member lookup. Why do you think it should be removed?<br class=""><br class="">-Joe<br class=""><br class="">_______________________________________________<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></div></blockquote></div><br class=""></div></body></html>