string enums

Adam D. Ruppe destructionator at gmail.com
Sat Apr 27 11:41:41 PDT 2013


I can't help too much with your problem because I tried it and it 
works for me (on my dmd 2.061), but the pattern you're doing 
there is actually unneeded:

enum Type {
    DOT, ID, MODULE, /* etc ....*/
}

would actually work and you can get a string out of it with 
std.conv.to:

import std.conv;

Type t = Type.DOT;

string s = to!string(t);

assert(s == "DOT");


More information about the Digitalmars-d-learn mailing list