Variable interpolation in strings

Adam D. Ruppe destructionator at gmail.com
Thu Jul 26 12:13:04 PDT 2012


It might be useful to do this kind of thing with a filter
function:

string escape(string s) { return s.replace("\n", "\\n"); }

auto foo = "cool\nstuff";
string lol = mixin(x("blah $foo", escape));

assert(lol == "blah cool\\nstuff");


More information about the Digitalmars-d mailing list