nested enum

Illuminati via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Aug 25 11:15:59 PDT 2016


On Thursday, 25 August 2016 at 01:37:05 UTC, Mike Parker wrote:
> 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);
> }

Thanks. I should have thought of that.


More information about the Digitalmars-d-learn mailing list