Thread overview | ||||||
---|---|---|---|---|---|---|
|
November 16, 2014 printing array of strings with writefln? | ||||
---|---|---|---|---|
| ||||
writefln("%(%s-%)", ["a", "b", "c"]) doesn't print the intended a-b-c but surrounds each string with double quotes - "a"-"b"-"c", which I find inconsistent with the fact that writefln("%s", "a string") prints the string without any quotes. How do I get the desired behaviour using just the format string? |
November 16, 2014 Re: printing array of strings with writefln? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Artem Tarasov | On Sunday, 16 November 2014 at 14:16:55 UTC, Artem Tarasov wrote: > writefln("%(%s-%)", ["a", "b", "c"]) doesn't print the intended a-b-c but surrounds each string with double quotes - "a"-"b"-"c", which I find inconsistent with the fact that writefln("%s", "a string") prints the string without any quotes. > How do I get the desired behaviour using just the format string? writefln("%-(%s-%)", ["a", "b", "c"]) http://ddili.org/ders/d.en/formatted_output.html |
November 16, 2014 Re: printing array of strings with writefln? | ||||
---|---|---|---|---|
| ||||
Posted in reply to JR | Thanks! The Ali's book is indeed superb, covering even such minor details. |
November 17, 2014 Re: printing array of strings with writefln? | ||||
---|---|---|---|---|
| ||||
Posted in reply to JR | On Sunday, 16 November 2014 at 15:08:10 UTC, JR wrote:
> On Sunday, 16 November 2014 at 14:16:55 UTC, Artem Tarasov wrote:
>> writefln("%(%s-%)", ["a", "b", "c"]) doesn't print the intended a-b-c but surrounds each string with double quotes - "a"-"b"-"c", which I find inconsistent with the fact that writefln("%s", "a string") prints the string without any quotes.
>> How do I get the desired behaviour using just the format string?
>
> writefln("%-(%s-%)", ["a", "b", "c"])
>
> http://ddili.org/ders/d.en/formatted_output.html
What I find surprising is that "%-(ch%)" without %s inside also works, although ch is prepended to each string and not a separator (which makes sense, but still). This does not seem to be mentioned in the documentation, neither in Ali's book. Is this a bug?
|
Copyright © 1999-2021 by the D Language Foundation