[swift-evolution] Working with enums by name

Brent Royal-Gordon brent at architechies.com
Tue May 31 16:48:59 CDT 2016


> |   enum Planet : Int {
> |      case Mercury = 1, Venus, Earth, Mars, Jupiter, Saturn, Uranus, Neptune
> |
> |      init?(caseName name : String) {

The compiler actually does this already through RawRepresentable if you put `String` as your raw type. So what's the use case for this? Code which needs both a non-String rawValue *and* needs to look up cases by name? How common do you think that is?

-- 
Brent Royal-Gordon
Architechies



More information about the swift-evolution mailing list