<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="">Oh, cool! I didn’t realize this syntax existed.<div class=""><br class=""></div><div class="">On May 5, 2016, at 10:52 AM, Krzysztof Siejkowski via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<div><blockquote type="cite" class=""><br class="Apple-interchange-newline"><div class=""><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: 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; margin: 0px;" class="">It doesn’t compile because you’re switching on the Optional and trying to pattern match it to Coin.</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: 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; margin: 0px;" class=""><br class=""></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: 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; margin: 0px;" class="">It compiles right when you pattern match it to Optional&lt;Coin&gt;:</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: 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; margin: 0px;" class=""><br class=""></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: 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; margin: 0px;" class=""><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Monaco;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">switch</span><span style="font-variant-ligatures: no-common-ligatures;" class=""><span class="Apple-converted-space">&nbsp;</span></span><span style="font-variant-ligatures: no-common-ligatures;" class="">result</span><span style="font-variant-ligatures: no-common-ligatures;" class=""><span class="Apple-converted-space">&nbsp;</span>{</span></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Monaco;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">case</span><span style="font-variant-ligatures: no-common-ligatures;" class=""><span class="Apple-converted-space">&nbsp;</span>.</span><span style="font-variant-ligatures: no-common-ligatures;" class="">heads</span><span style="font-variant-ligatures: no-common-ligatures;" class="">?:<span class="Apple-converted-space">&nbsp;</span></span><span style="font-variant-ligatures: no-common-ligatures;" class="">print</span><span style="font-variant-ligatures: no-common-ligatures;" class="">(</span><span style="font-variant-ligatures: no-common-ligatures;" class="">"heads"</span><span style="font-variant-ligatures: no-common-ligatures;" class="">)</span></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Monaco;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">case</span><span style="font-variant-ligatures: no-common-ligatures;" class=""><span class="Apple-converted-space">&nbsp;</span>.</span><span style="font-variant-ligatures: no-common-ligatures;" class="">tails</span><span style="font-variant-ligatures: no-common-ligatures;" class="">?:<span class="Apple-converted-space">&nbsp;</span></span><span style="font-variant-ligatures: no-common-ligatures;" class="">print</span><span style="font-variant-ligatures: no-common-ligatures;" class="">(</span><span style="font-variant-ligatures: no-common-ligatures;" class="">"tails"</span><span style="font-variant-ligatures: no-common-ligatures;" class="">)</span></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Monaco;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">case</span><span style="font-variant-ligatures: no-common-ligatures;" class=""><span class="Apple-converted-space">&nbsp;</span></span><span style="font-variant-ligatures: no-common-ligatures;" class="">nil</span><span style="font-variant-ligatures: no-common-ligatures;" class="">:<span class="Apple-converted-space">&nbsp;</span></span><span style="font-variant-ligatures: no-common-ligatures;" class="">print</span><span style="font-variant-ligatures: no-common-ligatures;" class="">(</span><span style="font-variant-ligatures: no-common-ligatures;" class="">"not yet flipped"</span><span style="font-variant-ligatures: no-common-ligatures;" class="">)</span></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Monaco;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">}</span></div></div><div style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: 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=""><br class=""></div><span style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: 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; float: none; display: inline !important;" class="">Best,</span><div style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: 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="">Krzysztof<br class=""><div id="bloop_sign_1462463405386560000" class="bloop_sign"></div><br class=""><p class="airmail_on">On 5 May 2016 at 17:42:24, Eric Miller via swift-evolution (<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>) wrote:</p><blockquote type="cite" class="clean_bq"><span class=""><div class=""><div class=""></div><div class=""><div dir="ltr" class="">Wondering if you guys think this is a reasonable idea.<div class=""><br class=""></div><div class="">I was switching on an optional enum today, and naturally gravitated towards including nil as a case:</div><div class=""><br class=""></div><div class="">enum Coin {</div><div class="">&nbsp; case heads</div><div class="">&nbsp; case tails</div><div class="">}</div><div class="">var result: Coin?</div><div class=""><br class=""></div><div class="">switch result {</div><div class="">case heads: print("heads")</div><div class="">case tails:&nbsp;print("tails")</div><div class="">case nil:&nbsp;print("not yet flipped") // exhaustive</div><div class="">}</div><div class=""><br class=""></div><div class="">Doesn't compile, and of course I can if-let or guard to unwrap instead, but I like the compactness of this.</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></div></span></blockquote></div><span style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: 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; float: none; display: inline !important;" class="">_______________________________________________</span><br style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: 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=""><span style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: 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; float: none; display: inline !important;" class="">swift-evolution mailing list</span><br style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: 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=""><a href="mailto:swift-evolution@swift.org" style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: 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="">swift-evolution@swift.org</a><br style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: 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=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: 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="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></div></blockquote></div><br class=""></div></body></html>