http://d.puremagic.com/issues/show_bug.cgi?id=7341



--- Comment #2 from Kenji Hara <k.hara...@gmail.com> 2012-04-21 06:26:55 PDT ---
(In reply to comment #0)
> D2 code:
> 
> import std.stdio;
> void main() {
>     int[] a1 = [1, 10, 5];
>     writefln("%12d", a1);
>     string[] a2 = ["red", "yellow", "ya"];
>     writefln("%12s", a2);
> }
> 
> Output:
> [           1,           10,            5]
> ["red", "yellow", "ya"]
> 
> But I expect an output more like:
> [           1,           10,            5]
> [       "red",     "yellow",         "ya"]

If you want to give format specifier for elements explicitly, you should use
compound format specifier (It is %( and %).)

    writefln("[%(%12d, %)]", [1, 10, 5]);
    writefln("[%(%12s, %)]", ["red", "yellow", "ya"]);

But, this code output:
[           1,           10,            5]
["red", "yellow", "ya"]

Because, string elements and character elements are treated specially. They are
quoted, and other specifications are ignored.

https://github.com/D-Programming-Language/phobos/blob/master/std/format.d#L1930

But, I agree it is debatable thing.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to