print enum value rather name from enum X : string

Marc jckj33 at gmail.com
Mon Feb 12 17:07:50 UTC 2018


If I have an enum like this:

> enum S  : string {
>	foo = "a",
>	baa = "b"
>}

when I printed it, to my surprise I get the enum field name 
rather value:

> writefln("%s v%s", S.foo, S.baa);	

output:

> foo vbaa

instead of

> a vb

a cast solves it but without cast everywhere I need that enum 
member, is there any other way to do it? otherwise I'll have to 
switch to a class with static immutable strings, right?



More information about the Digitalmars-d-learn mailing list