<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="">You should join your efforts to the&nbsp;<a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151221/003819.html" class="">"Enum 'count' functionality"</a>&nbsp;thread, where this is also being discussed.</div><br class=""><div class="">
<span class="Apple-style-span" style="border-collapse: separate; line-height: normal; border-spacing: 0px;">Félix</span>
</div>

<br class=""><div><blockquote type="cite" class=""><div class="">Le 23 déc. 2015 à 17:41:13, Anthony Miller via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; a écrit :</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=us-ascii" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><pre class=""><font face="Helvetica" class="">Rough proposal for implementing a method to get all cases on a enum. I feel like this is a valuable feature, and all current methods of doing this have major drawbacks. I'd like to field the idea to gauge interest.</font></pre><pre class=""><font face="Helvetica" class="">Thank You,
</font><span style="font-family: Helvetica; white-space: normal;" class="">Anthony Miller<br class=""></span><span style="font-family: Helvetica; white-space: normal;" class="">Lead iOS Developer,&nbsp;</span><a href="http://app-order.com/" class="" style="font-family: Helvetica; white-space: normal;">App-Order.com</a>
<span style="font-family: Helvetica; white-space: normal;" class="">Mobile: 702-334-8454</span></pre><pre class=""></pre></div></div><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><pre class=""># Collection of all cases for an Enum

## Introduction</pre><pre class="">Add reflection capabilities for getting an `Array` or `Set` of all cases for an Enum. </pre><pre class="">This would not be supported for enums with associated values.</pre><pre class="">## Motivation<br class=""></pre><pre class="">This feature provides a benefit for many&nbsp;use cases.&nbsp;</pre><pre class="">Multiple methods of doing this exist currently, however each has obvious drawbacks.</pre><pre class="">For an summary of current methods, see: <a href="http://stackoverflow.com/questions/24007461/how-to-enumerate-an-enum-with-string-type/24137319#24137319" class="">http://stackoverflow.com/questions/24007461/how-to-enumerate-an-enum-with-string-type/24137319#24137319</a></pre><pre class="">## Proposed solution
<br class=""></pre><pre class=""><pre class="">This could be implemented as a static function or static constant.&nbsp;</pre><pre class="">    enum Foo {
        case CaseOne, CaseTwo, CaseThree
    }
    
    let allCases: [Foo] = Foo.allCases()    // [.CaseOne, .CaseTwo, .CaseThree]    </pre><pre class=""><br class=""></pre><pre class="">Alternatively, an extension of `Mirror` to support mirrors of types could include this capability.</pre><pre class=""><br class=""></pre></pre></div></div></div><br class="">
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=iRI3beHTe3UxYAHTlV3lA38zIPfHMhyuRzgTmGKV6k6UK0LwQgK4QTDokC7xWFd-2FYNXzhw1IMiynl2VhSuCQfHsIvq8tTsG-2Bxrnj2KcXPwqfRAviPNrQQ2rekkaTG62FmXK6zDUbi-2FBKdcxAJup4FZ-2BKXGDlak2tihEHdFUZ-2BySs9hil6YevIJoS7UgJUPQQGoOvfbtSmIXOOu8-2FpMhnyKHtqO-2F9UNvGQceA0kx-2BkIs-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;" class="">
</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=""></body></html>