> On May 31, 2016, at 4:48 PM, Brent Royal-Gordon via swift-evolution 
> <[email protected]> wrote:
> 
>> |   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?

How about a LogCategory enum:

• whose name is printed with each log entry (and thus wants a String raw type),
• which can be configured from command line or config file (and thus wants 
string-based lookup), but
• also wants OptionSetType-like behavior (and thus an Int raw type).

P

_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to