<div>+1 as for compleax enums it really does get messy. Leave the current approach in place, though.</div><div><br></div><div>I&#39;m not sure the syntax is best though. Maybe we could just open a curly brace right after the enum case declaration and put the specific function there. Same way everything out of the braces is considered a _default_ case.</div><div><br><div class="gmail_quote"><div>On Sun, 8 Jan 2017 at 14:12 Anton Zhilin via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_msg"><div class="m_8102798602507343821markdown-here-wrapper gmail_msg"><p style="margin:0px 0px 1.2em!important" class="gmail_msg">It would be nice if for each enum case, there was a computed property returning an optional. Then you could do:</p><br><br><pre style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;font-size:1em;line-height:1.2em;margin:1.2em 0px" class="gmail_msg"><code class="m_8102798602507343821hljs m_8102798602507343821language-swift gmail_msg" style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline;white-space:pre-wrap;overflow:auto;border-radius:3px;border:1px solid rgb(204,204,204);padding:0.5em 0.7em;display:block!important;display:block;overflow-x:auto;padding:0.5em;color:rgb(51,51,51);background:rgb(248,248,248)"><span class="m_8102798602507343821hljs-class gmail_msg"><span class="m_8102798602507343821hljs-keyword gmail_msg" style="color:rgb(51,51,51);font-weight:bold">enum</span> <span class="m_8102798602507343821hljs-title gmail_msg" style="color:rgb(153,0,0);font-weight:bold;color:rgb(68,85,136);font-weight:bold">FooBar</span> </span>{<br><br>    <span class="m_8102798602507343821hljs-keyword gmail_msg" style="color:rgb(51,51,51);font-weight:bold">case</span> foo(<span class="m_8102798602507343821hljs-type gmail_msg" style="color:rgb(68,85,136);font-weight:bold">Int</span>)<br><br>    <span class="m_8102798602507343821hljs-keyword gmail_msg" style="color:rgb(51,51,51);font-weight:bold">case</span> bar(<span class="m_8102798602507343821hljs-type gmail_msg" style="color:rgb(68,85,136);font-weight:bold">Int</span>)<br><br>}<br><br><br><br><span class="m_8102798602507343821hljs-keyword gmail_msg" style="color:rgb(51,51,51);font-weight:bold">let</span> x = <span class="m_8102798602507343821hljs-type gmail_msg" style="color:rgb(68,85,136);font-weight:bold">FooBar</span>.foo(<span class="m_8102798602507343821hljs-number gmail_msg" style="color:rgb(0,128,128)">42</span>)<br><br>x.foo  <span class="m_8102798602507343821hljs-comment gmail_msg" style="color:rgb(153,153,136);font-style:italic">//=&gt; Optional(42)</span><br><br>x.bar  <span class="m_8102798602507343821hljs-comment gmail_msg" style="color:rgb(153,153,136);font-style:italic">//=&gt; nil</span><br><br></code></pre><br><br><p style="margin:0px 0px 1.2em!important" class="gmail_msg">This feature has been discussed many times, but each time it was considered “out of scope”.</p><br><br><div title="MDH:SXQgd291bGQgYmUgbmljZSBpZiBmb3IgZWFjaCBlbnVtIGNhc2UsIHRoZXJlIHdhcyBhIGNvbXB1&lt;br&gt;&lt;br&gt;dGVkIHByb3BlcnR5IHJldHVybmluZyBhbiBvcHRpb25hbC4gVGhlbiB5b3UgY291bGQgZG86PGRp&lt;br&gt;&lt;br&gt;dj48YnI+PC9kaXY+PGRpdj5gYGBzd2lmdDwvZGl2PjxkaXY+ZW51bSBGb29CYXIgezwvZGl2Pjxk&lt;br&gt;&lt;br&gt;aXY+Jm5ic3A7ICZuYnNwOyBjYXNlIGZvbyhJbnQpPC9kaXY+PGRpdj4mbmJzcDsgJm5ic3A7IGNh&lt;br&gt;&lt;br&gt;c2UgYmFyKEludCk8L2Rpdj48ZGl2Pn08L2Rpdj48ZGl2Pjxicj48L2Rpdj48ZGl2PmxldCB4ID0g&lt;br&gt;&lt;br&gt;Rm9vQmFyLmZvbyg0Mik8L2Rpdj48ZGl2PnguZm9vICZuYnNwOy8vPSZndDsgT3B0aW9uYWwoNDIp&lt;br&gt;&lt;br&gt;PC9kaXY+PGRpdj54LmJhciAmbmJzcDsvLz0mZ3Q7IG5pbDwvZGl2PjxkaXY+YGBgPC9kaXY+PGRp&lt;br&gt;&lt;br&gt;dj48YnI+PC9kaXY+PGRpdj5UaGlzIGZlYXR1cmUgaGFzIGJlZW4gZGlzY3Vzc2VkIG1hbnkgdGlt&lt;br&gt;&lt;br&gt;ZXMsIGJ1dCBlYWNoIHRpbWUgaXQgd2FzIGNvbnNpZGVyZWQgIm91dCBvZiBzY29wZSIuPC9kaXY+" style="height:0;width:0;max-height:0;max-width:0;overflow:hidden;font-size:0em;padding:0;margin:0" class="gmail_msg">​</div></div></div><br><br>_______________________________________________<br class="gmail_msg"><br>swift-evolution mailing list<br class="gmail_msg"><br><a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a><br class="gmail_msg"><br><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" class="gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="gmail_msg"><br></blockquote></div></div>