String interpolation

mw mingwu at gmail.com
Thu May 21 06:57:28 UTC 2020


On Thursday, 21 May 2020 at 01:13:27 UTC, Paul Backus wrote:
> On Wednesday, 20 May 2020 at 23:41:15 UTC, mw wrote:
>> Can we do string interpolation in D now?
>
> There's an implementation in the dub package "scriptlike":
>
> https://code.dlang.org/packages/scriptlike#string-interpolation

Thank you! very nice:

// Output: The number 21 doubled is 42!
int num = 21;
writeln( mixin(interp!"The number ${num} doubled is ${num * 2}!") 
);

Is there any way to make it shorter? e.g.

writeln( s!"The number ${num} doubled is ${num * 2}!" );

i.e how to write this 's'?



More information about the Digitalmars-d-learn mailing list