enum

Walter Bright newshound2 at digitalmars.com
Tue Apr 8 14:21:29 PDT 2014


On 4/8/2014 2:16 PM, Dicebot wrote:
> On Tuesday, 8 April 2014 at 21:12:10 UTC, Walter Bright wrote:
>> 6. An integral type, some of which have names:
>>
>> enum Color {
>>     Red = 0xFF0000,
>>     Green = 0x00FF00,
>>     Blue = 0x0000FF00,
>>     Fred = 0x123456,
>>     White = 0xFFFFFF }
>
> This is not an integral type but collection of named constants with shared
> qualified path. Probably most common use case and one that should not have been
> part of enum design but a separate concept.

The thing is, I want to be able to name that type:

     void setColor(Color newcolor) { ... }

Having a bunch of named constants doesn't do that.


More information about the Digitalmars-d mailing list