Why does this snippet print the enum identifiers instead of their values?

Jesse Phillips Jesse.K.Phillips+D at gmail.com
Tue May 28 07:35:21 PDT 2013


I do not believe this is a bug. You should be able to print the 
value by casting to string. (to!() will not work as it will 
provide the same results)

Usually enumeration values are not descriptive for how they 
should be used. And when printing to the screen it is usually for 
debugging or some other task where a meaningful name would be 
better.

String enum's are a little different since there value can be 
fairly descriptive. But still they usually are not descriptive 
about how they should be used. And it would be odd for enum of 
int to print the enum name while string enum to print the value.


More information about the Digitalmars-d-learn mailing list