Function interp
Interpolated string (ie, variable expansion).
Any D expression can be placed inside ${ and }. Everything between the curly braces will be evaluated inside your current scope, and passed as a parameter (or parameters) to std.conv.text.
The curly braces do NOT nest, so variable expansion will end at the first closing brace. If the closing brace is missing, an Exception will be thrown at compile-time.
Prototype
string interp(string str)();
Example
// Output: The number 21 doubled is 42!
int num = 21;
writeln( mixin(interp!"The number ${num} doubled is ${num * 2}!") );
// Output: Empty braces output nothing.
writeln( mixin(interp!"Empty ${}braces ${}output nothing.") );
// Output: Multiple params: John Doe.
auto first = "John", last = "Doe";
writeln( mixin(interp!`Multiple params: ${first, " ", last}.`) );
Authors
Nick Sabalausky
Copyright
Copyright (C) 2014-2016 Nick Sabalausky