nested enum

Mike Parker via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Aug 24 18:37:05 PDT 2016


On Wednesday, 24 August 2016 at 23:04:25 UTC, Illuminati wrote:
> How can I create nested enum like structures?
>
> instead of Enum.X_Y I would like to access like Enum.X.Y
>
> Yet I want it to behave exactly as an enum.  I just want to not 
> use _ as .'s are better as they express more clearly what I 
> want.

struct MyEnum {
     enum X { Y = 10, Z = 20 }
}

void main() {
     import std.stdio;
     int y = MyEnum.X.Y;
     writeln(y);
}


More information about the Digitalmars-d-learn mailing list