Interpolated strings
Stanislav Blinov via Digitalmars-d
digitalmars-d at puremagic.com
Sat Apr 15 13:20:49 PDT 2017
On Saturday, 15 April 2017 at 20:12:41 UTC, cym13 wrote:
> On Saturday, 15 April 2017 at 20:04:13 UTC, Jonas Drewsen wrote:
> This has been proposed before, and I still don't see the added
> value compared to:
>
> auto a=7;
> writeln(a, " times 3 is ", a*3);
>
> besides adding compiler complexity, language complexity and
> parsing complexity which leaves room for more bugs to be
> invented. I'm a bit more harsh than I could be, but if this
> simple question has no clear answer I don't see why it sould
> make it into the language.
Try a different context:
auto a = 7;
import std.format;
auto str = format("%s times 3 is %s", a, a*3);
//or
import std.conv;
auto str = text(a, " times 3 is ", a*3);
//or
auto str = $"{a} times 3 is {a*3}";
More information about the Digitalmars-d
mailing list