Bug 3999 and 4261

Jonathan M Davis jmdavisprog at gmail.com
Wed Sep 1 14:14:48 PDT 2010


On Wednesday, September 01, 2010 13:53:51 Andrej Mitrovic wrote:
> I thought to!string(Enum) already does this? This was the example I
> posted in bug report 4261:
> 
> import std.conv : to;
> import std.stdio: writeln;
> void main()
> {
>     enum Foo { Zero, One }
>     Foo f = Foo.One;
>     writeln(to!string(f));
> }
> 
> Prints: One

Well, like I said, it never occurred to me that you even could print enums as 
strings in D, so I don't know how it's typically done. However, if it's as 
simple as that, I don't really see what the problem is. Sure, it would be nice 
if they printed as strings by default rather than the generally useless base 
type of int or whatever, but using to!string like that is quite straightforward.

- Jonathan M Davis


More information about the Digitalmars-d mailing list