formattedWrite writes nothing
ref2401 via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri May 2 03:06:40 PDT 2014
class MyClass {
Appender!string _stringBuilder;
this() {
_stringBuilder = Appender!string(null);
_stringBuilder.clear();
}
@property string str() {
return _stringBuilder.data;
}
void append(string s) {
formattedWrite(_stringBuilder, "%s", s);
}
}
MyClass c = new MyClass();
c.append("text 1");
c.append("__222");
writeln(c.str); //in this case nothing is printed out
Following workarounds work:
1) call _stringBuilder.put() instead of formattedWrite()
2) if "_stringBuilder.clear()" is omitted in the constructor,
formattedWrite(...) will work as expected.
Is it a bug or is there a reason for such behaviour?
More information about the Digitalmars-d-learn
mailing list