[swift-evolution] [Proposal] Allow enumerating cases in enumerations

Karl razielim at gmail.com
Mon Jul 4 10:34:50 CDT 2016


> On 4 Jul 2016, at 09:14, Brent Royal-Gordon via swift-evolution <swift-evolution at swift.org> wrote:
> 
>> On Jul 3, 2016, at 6:36 PM, Gabriel Lanata via swift-evolution <swift-evolution at swift.org> wrote:
>> 
>> Hello, this has been proposed multiple times before in different ways. 
> 
> It has indeed. Unfortunately, for various reasons it did not get into review in time, and Swift 3 is basically closed to additive features at this point. Our last pull request to get it reviewed has now been tagged "out of scope for current release". <https://github.com/apple/swift-evolution/pull/114>
> 
>> The proposed solution is to implement a native `.cases` static var for all enumerations without associated values. 
> 
> 
> That was one of many things we discussed in previous threads. `cases` isn't good because the natural variable you'd want to use in a `for` loop is `case`:
> 
> 	for case in PokemonType.cases { … }
> 
> And also because other types which aren't technically enums, such as `Bool`, may want to expose their "cases" through the same mechanism.
> 

Now that you mention it; why is Bool not an enum?

Karl
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160704/48a6053f/attachment.html>


More information about the swift-evolution mailing list