foreach with enum
BCS
ao at pathlink.com
Thu Jul 19 14:21:42 PDT 2007
Reply to Vladimir,
> On Thu, 19 Jul 2007 23:14:59 +0300, Thomas Mader <thezema at gmail.com>
> wrote:
>
>> I am just porting some of my little Java programs to D to get
>> comfortable with the langugage and realized that I cannot use foreach
>> with Enums.
>>
>> In Java I can do:
>>
>> enum Color { Kreuz, Pik, Herz, Karo }
>>
>> for(Color color : Color.values()) {}
>>
>> AFAIK thats not possible in D yet.
>>
> for (Color color=Color.min; color<=Color.max; color++)
> writefln(color);
enum Color { Kreuz = 1, Pik = 2, Herz = 4, Karo = 8 }
More information about the Digitalmars-d
mailing list