Thread overview | ||||||
---|---|---|---|---|---|---|
|
December 04, 2009 Explicit ordering with std.format | ||||
---|---|---|---|---|
| ||||
An extract from java.util.Formatter docs: // Explicit argument indices may be used to re-order output. formatter.format("%4$2s %3$2s %2$2s %1$2s", "a", "b", "c", "d") // -> " d c b a" How do I achieve this with std.format? The ddocs only say that "variadic arguments are consumed in order". Any way to change that order? Tomek |
December 05, 2009 Re: Explicit ordering with std.format | ||||
---|---|---|---|---|
| ||||
Posted in reply to Tomek Sowiński | Tomek Sowiñski:
> How do I achieve this with std.format?
I think you can't (and I haven't had the need to do it).
Bye,
bearophile
|
December 05, 2009 Re: Explicit ordering with std.format | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile | bearophile wrote:
> Tomek Sowiñski:
>> How do I achieve this with std.format?
>
> I think you can't (and I haven't had the need to do it).
It's somtimes needed with I18N code.
|
December 06, 2009 Re: Explicit ordering with std.format | ||||
---|---|---|---|---|
| ||||
Posted in reply to Tomek Sowiński | Tomek Sowiński wrote:
> An extract from java.util.Formatter docs:
>
> // Explicit argument indices may be used to re-order output.
> formatter.format("%4$2s %3$2s %2$2s %1$2s", "a", "b", "c", "d")
> // -> " d c b a"
>
> How do I achieve this with std.format? The ddocs only say that "variadic arguments are consumed in order". Any way to change that order?
>
>
> Tomek
With the D Tango library you can put:
Stdout.format("{3} {2} {1} {0}", "a", "b", "c", "d");
|
Copyright © 1999-2021 by the D Language Foundation