nested enum
Daniel Kozak via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Aug 24 22:06:43 PDT 2016
And if you need more levels:
struct MyEnum {
static struct AnotherEnum {
enum X { Y = 10, Z = 20 }
}
}
void main() {
import std.stdio;
int y = MyEnum.AnotherEnum.X.Y;
writeln(y);
}
Dne 25.8.2016 v 03:37 Mike Parker via Digitalmars-d-learn napsal(a):
> 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