On Thursday, 18 November 2021 at 16:08:22 UTC, Paul Backus wrote:
On Thursday, 18 November 2021 at 13:51:42 UTC, Martin Tschierschke wrote:
[...]

You can define a `toString` method, like this:

```d
string toString()
{
    import std.conv;
    return p.to!string;
}
```

You can find more information about `toString` in the documentation here: https://dlang.org/phobos/std_format_write.html

By the way, the reason your original version does not work is that `p` is `private`, so `writeln` cannot access it. If you change `p` to be `public`, it will work without a `toString` method.

I thought private was to the module/file, not class/struct?

Jordan

Reply via email to