-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Closed
Labels
compilerThe Swift compiler itselfThe Swift compiler itselfenumFeature → type declarations: Swift enumeration declarationsFeature → type declarations: Swift enumeration declarationsfeatureA feature request or implementationA feature request or implementationimprovementswift evolution implementedFlag → feature: A feature that was approved through the Swift evolution process and implementedFlag → feature: A feature that was approved through the Swift evolution process and implemented
Description
Previous ID | SR-30 |
Radar | rdar://problem/17102392 |
Original Reporter | RuiCarneiro (JIRA User) |
Type | Improvement |
Status | Resolved |
Resolution | Done |
Additional Detail from JIRA
Votes | 6 |
Component/s | |
Labels | Improvement, LanguageFeatureRequest |
Assignee | @CodaFi |
Priority | Medium |
md5: 6f9747e0e0648c9bf5fee84b0f66cd7f
relates to:
- SR-3050 enum cases should be enumerable
Issue Description:
Sometimes, it's convenient to have an allValues property for an enum that automatically generates a collection with all possible elements.
eg:
{{enum Fruits { case Apple, Orange, Peach, Banana }
for fruit in Fruits.allValues {
// ...
}}}
{color:red}On another note, it would be handy to have a reverse function for the rawValue propriety
eg:
{{enum Fruits : Int { case Apple = 0, Orange ... }
let fruit : Fruits? = Fruits.reverseRawValue(1)
// fruit == Fruits.Orange}}{color}
Thanks, Kevin Ballard.
Metadata
Metadata
Assignees
Labels
compilerThe Swift compiler itselfThe Swift compiler itselfenumFeature → type declarations: Swift enumeration declarationsFeature → type declarations: Swift enumeration declarationsfeatureA feature request or implementationA feature request or implementationimprovementswift evolution implementedFlag → feature: A feature that was approved through the Swift evolution process and implementedFlag → feature: A feature that was approved through the Swift evolution process and implemented