digitalmars.D.learn - Multiple %s format specifiers with a single argument
- Andrej Mitrovic (13/13) Apr 09 2012 import std.string;
- q66 (2/18) Apr 09 2012 Positional specifier works just fine for me.
- Andrej Mitrovic (2/3) Apr 09 2012 Which version are you using? I'm on 2.058.
- =?UTF-8?B?QWxpIMOHZWhyZWxp?= (6/9) Apr 09 2012 Positional parameters[*] are supported in 2.058. This example prints the...
- q66 (2/5) Apr 09 2012 git
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 std\format.d(4363): string That's a great error message btw.
Apr 09 2012
On Monday, 9 April 2012 at 17:09:03 UTC, Andrej Mitrovic wrote: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 std\format.d(4363): string That's a great error message btw.Positional specifier works just fine for me.
Apr 09 2012
On 4/9/12, q66 <quaker66 gmail.com> wrote:Positional specifier works just fine for me.Which version are you using? I'm on 2.058.
Apr 09 2012
On 04/09/2012 10:24 AM, Andrej Mitrovic wrote:On 4/9/12, q66<quaker66 gmail.com> wrote:Positional parameters[*] are supported in 2.058. This example prints the same argument in decimal, hexadecimal, octal, and binary: writefln("%1$d %1$x %1$o %1$b", 42); Ali [*] http://ddili.org/ders/d.en/formatted_output.htmlPositional specifier works just fine for me.Which version are you using? I'm on 2.058.
Apr 09 2012
On Monday, 9 April 2012 at 17:24:35 UTC, Andrej Mitrovic wrote:On 4/9/12, q66 <quaker66 gmail.com> wrote:gitPositional specifier works just fine for me.Which version are you using? I'm on 2.058.
Apr 09 2012