On Tuesday, 10 November 2015 at 10:21:32 UTC, tired_eyes wrote:
Hi,
The only example of string interpolation I've found so far is on Rosetta Code:

void main() {
    import std.stdio, std.string;

    "Mary had a %s lamb.".format("little").writeln;
"Mary had a %2$s %1$s lamb.".format("little", "white").writeln;
}

Is this a "proper" way of string interpolation in D? This looks a little clumsy. Are there any better approaches? Quick skimming through the docs didn't give anything.

Whats clumsy about it?

If it's the style (excessive use of UFCS), I'd have to agree with you.
Could easily have been written as:
   format("Mary had a %s lamb", "little");

which I personally think is more readable...

Reply via email to