Question

How to iterate over enums ?

It is donot work

enum Bool : int { no = 0, yes }
Bool boll;
foraech( e, bool){
    writeln(e);
}
Was it helpful?

Solution

There are so many mistakes within your code, so I just give you a code that works:

import std.stdio;
import std.traits;

void main() {
    enum Bool { no = 0, yes }
    foreach (e; [EnumMembers!Bool]) {
        writeln(e);
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top