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?




Reply via email to