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

Bart Whiteley bwhiteley at gmail.com
Tue Dec 22 11:10:10 CST 2015


On Mon, Dec 21, 2015 at 1:42 AM, Andyy Hope via swift-evolution <
swift-evolution at swift.org> wrote:

> Hi Swift Team and Community
>
> I’ve put a proposal up on GitHub to add a cases ‘count’ functionality to
> Enums for the Swift language
> https://gist.github.com/andyyhope/2fc5b6bee8ee1346f688
>
>
> Comments, feedback, scenario appends very much welcomed. Thank you
>

I would discourage adding just a `.count`. I've heard a few people ask for
this over the last year. In almost all cases it is due to people falling
back to the way they dealt with enums in Objective C when in fact there is
usually a better way in Swift.  Adding `.count` would inhibit the discovery
of better ways of doing things.

However, I'm having a hard time arguing against `.cases`. In at least one
place I currently have an `.allCases` computed property on an enum.

--
bart
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151222/a82f00f7/attachment.html>


More information about the swift-evolution mailing list