Interpolated strings?

Andy Valencia dont at spam.me
Mon Dec 16 20:33:27 UTC 2024


I have a string full of JavaScript to serve up, and a couple 
variable values need to be interpolated into it.  I read that 
dlang now has interpolated strings under i"...", so yay!  A bit 
of example code to show what I tried:

string s;
int i
auto x = i"Message $(s) has value $(i)"
writeln(x)

and it worked as expected.  But:

string x = i"Message $(s) has value $(i)"

instead does NOT work.  And there's no toString, nor does 
to!string do the trick.  The core.interpolation file has no 
unittest, so I can't crib from anything there.  How _does_ one 
get the string post-interpolation?

This is with ldc2-1.40.0-beta4-linux-x86_64

Thanks,
Andy Valencia



More information about the Digitalmars-d-learn mailing list