Interpolated strings

Adam D. Ruppe via Digitalmars-d digitalmars-d at puremagic.com
Thu Apr 20 11:33:37 PDT 2017


On Thursday, 20 April 2017 at 18:28:30 UTC, Atila Neves wrote:
> writeln($"{a} times 3 is {a * 3}");
>
> is even marginally better than
>
> writeln(a, " times 3 is ", a * 3);  // look ma, works right now!

Matching up the correct commas and quotes is a bit of a pain in 
the latter.

Though I don't think it is a big deal... I think most string 
building is a mistake anyway, as in you should find some entirely 
different way to it rather than embedding variables like that. 
But if I am going to do it it, the writeln(a, ",", "\") is like 
my least favorite way (yet I use it a lot because it is in there)


More information about the Digitalmars-d mailing list