Yes, you can do all this but you still have to do everything yourself by hand. Dictionary, plist, it even init as my initial example but you are the one responsible to control when e.g. you add a new value or rename another.
My proposal causes no big changes and no big overload on the compiler; it just adds an init method to find the equivalent enum value for a string. And yes this feature becomes a lot more interesting should the idea of using tuple typed enums goes forward but they are completely independent. L -----Original Message----- From: "Patrick Smith" <[email protected]> Sent: 01/06/2016 04:52 AM To: "Brent Royal-Gordon" <[email protected]> Cc: "Leonardo Pessoa" <[email protected]>; "Swift-evolution" <[email protected]> Subject: Re: [swift-evolution] Working with enums by name I had no idea you could do this!! > On 1 Jun 2016, at 12:32 PM, Brent Royal-Gordon via swift-evolution > <[email protected]> wrote: > > Who said anything about repeating the name? > > Welcome to Apple Swift version 2.2 (swiftlang-703.0.18.8 clang-703.0.30). > Type :help for assistance. > 1> enum Planet: String { case mercury, venus, earth, mars, jupiter, saturn, > uranus, neptune } > 2> Planet.mercury.rawValue > $R0: String = "mercury"
_______________________________________________ swift-evolution mailing list [email protected] https://lists.swift.org/mailman/listinfo/swift-evolution
