[swift-evolution] Proposal: Enum 'count' functionality

Extelligent Cocoa extelligentcocoa at extelligentcocoa.org
Wed Dec 23 06:29:18 CST 2015

Brent Royal-Gordon <mailto:swift-evolution at swift.org> wrote:

> I think we'd be much better off having a list of all cases. That would 
> make this feature useful for enums which don't have a raw type, or 
> don't use Int as their raw type, or don't use sequential raw values 
> for their cases.
> That approach has been discussed before, but not formally proposed.
I'd just like to +1 this as it's a feature I often use - enums are 
perfect for limiting user choices (days of the week, anyone?) and having 
to manually create and update the list of cases would be much easier and 
safer with a dedicated feature. (I'd prefer for it not to be a set 
because a set has no inbuilt order; if it were returned as a set I'd 
then have to create an array manually anyway; I want my weekdays to 
appear neither randomly sorted nor alphabetical.

Catja Pafort

More information about the swift-evolution mailing list