iterate over enum name:value pairs

Jay Norwood jayn at prismnet.com
Sun Dec 8 19:51:23 PST 2013


Thanks.  That's looking pretty clean.

I had already tried the shorter enum names without using the with 
statement, and it failed to compile.  I thought it might work 
since the struct definition already specifies the enum type for 
the two members.


>
>     with (Suit) with (SuitShort)
>     {
>         static Suits[] suits = [
>             {spades,    1,  6, spd},
>             {hearts,    4, 10, hrt},
>             {diamonds,  4, 10, dmd},
>             {clubs,    10, 16, clb}
>         ];
>
>         foreach (immutable member;  suits)
>         ...
>
>
> Bye,
> bearophile



More information about the Digitalmars-d-learn mailing list