سؤال

How to iterate over enums ?

It is donot work

enum Bool : int { no = 0, yes }
Bool boll;
foraech( e, bool){
    writeln(e);
}
هل كانت مفيدة؟

المحلول

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);
    }
}
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top