On 03/17/2010 11:21 AM, Gabriel Laskar wrote:

I have another problem :

1 import std.stdio;
2 import std.string;
3
4 int main()
5 {
6 char[][] a = ["expected %s but found %s".dup, "42".dup, "32".dup];
7
8 writeln(format(a[0], a[1 .. $]));
9
10 return 0;
11 }

Does not work :
$ dmd-phobos -run format.d
std.format.FormatError: std.format

format wants to put the entire a[1 .. $] in the first %s. There isn't anything left over for the second %s

but :

1 import std.stdio;
2 import std.string;
3
4 int main()
5 {
6 char[][] a = ["expected %s".dup, "42".dup];
7
8 writeln(format(a[0], a[1 .. $]));
9
10 return 0;
11 }

does not seems to work either :
$ dmd-phobos -run format.d
expected [42]

Did I miss something ?


ditto.

To get what you want, you're probably going to have to mess around with std.format.doFormat and implement your own format function.

Reply via email to