[swift-evolution] Working with enums by name
me at lmpessoa.com
Wed Jun 1 05:29:28 CDT 2016
In this case of not using raw values in an enum, can you use init(rawValue:) as in my proposal?
From: "Charlie Monroe via swift-evolution" <swift-evolution at swift.org>
Sent: 01/06/2016 07:19 AM
To: "Brent Royal-Gordon" <brent at architechies.com>
Cc: "Swift-evolution" <swift-evolution at swift.org>
Subject: Re: [swift-evolution] Working with enums by name
Sorry, must've missed that.
> On Jun 1, 2016, at 12:17 PM, Brent Royal-Gordon <brent at architechies.com> wrote:
>> This is, however, kind of a hack IMHO that relies on the compiler behavior that isn't well documented.
> It's documented in "The Swift Programming Language", in the same paragraphs where the `enum Planet` example we've been working with comes from.
> “When you’re working with enumerations that store integer or string raw values, you don’t have to explicitly assign a raw value for each case. When you don’t, Swift will automatically assign the values for you.
> “When strings are used for raw values, the implicit value for each case is the text of that case’s name.”
> Brent Royal-Gordon
swift-evolution mailing list
swift-evolution at swift.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution