On Thursday, 10 April 2014 at 11:40:46 UTC, monarch_dodra wrote:
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`, ")");
  }

Thanks. But the question was not about how to print it to console, but whether there are any hidden dangers in using Appender in this way, like the one Rene mentioned.

Reply via email to