Customizing printing of structs (writeln / to!sth behavior).

ciechowoj via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Feb 15 04:03:44 PST 2016


It there a way to change how writeln converts structs to strings? 
I read in the documentation it uses to!string to convert the 
struct. Is there a way to overload to!string for my own type?

Let say I have:

struct Point {
     int x, y;
}

and I want writeln(Point(3, 4)); to print "[3, 4]" instead of 
"Point(3, 4)".



More information about the Digitalmars-d-learn mailing list