Multiple %s format specifiers with a single argument
Andrej Mitrovic
andrej.mitrovich at gmail.com
Mon Apr 9 10:08:54 PDT 2012
import std.string;
void main()
{
string foo = "foo";
string bar = format("%s %s %s", foo);
}
format expects 3 arguments, but what I really want is foo to be used
for all 3 specifiers and not repeat 'foo' 3 times manually. Are there
any format specifiers that do what I want? I've tried using positional
specifiers but that didn't work:
string bar = format("%1$s %1$s %1$s", foo);
$ std.format.FormatException at std\format.d(4363): string
That's a great error message btw.
More information about the Digitalmars-d-learn
mailing list