Design with appender: good or bad?
monarch_dodra
monarchdodra at gmail.com
Thu Apr 10 04:40:45 PDT 2014
On Thursday, 10 April 2014 at 10:16:43 UTC, Chris wrote:
> because the two are not the same. When you print MyStruct to
> console you get the address of appender buf, whereas when you
> use string[] items you get the actual items. I'm only
> wondereing if using appender is potentially dangerous and could
> bite me later.
Why don't you implement "toString" on your type?
void toString(scope void delegate(const(char)[]) sink)
{
import std.format;
formattedWrite(sink, `%s`, "MyStruct(");
formattedWrite(sink, `"%s"`, name);
formattedWrite(sink, `%s`, ", ");
formattedWrite(sink, `%s`, buf.data);
formattedWrite(sink, `%s`, ")");
}
More information about the Digitalmars-d-learn
mailing list