iterate over enum name:value pairs
Jay Norwood
jayn at prismnet.com
Sat Dec 7 08:39:55 PST 2013
In Ali Çehreli very nice book there is this example of iterating
over enum range which, as he notes, fails
http://ddili.org/ders/d.en/enum.html
enum Suit { spades, hearts, diamonds, clubs }
foreach (suit; Suit.min .. Suit.max) {
writefln("%s: %d", suit, suit);
}
spades: 0
hearts: 1
diamonds: 2
← clubs is missing
It seems like there is interest in iterating over the name:value
pairs of an enum. Is this is already available with some D
programming trick?
More information about the Digitalmars-d-learn
mailing list