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.

string
interp
(
string str
)
(
)

Examples

1 // Output: The number 21 doubled is 42!
2 int num = 21;
3 writeln( mixin(interp!"The number ${num} doubled is ${num * 2}!") );
4 
5 // Output: Empty braces output nothing.
6 writeln( mixin(interp!"Empty ${}braces ${}output nothing.") );
7 
8 // Output: Multiple params: John Doe.
9 auto first = "John", last = "Doe";
10 writeln( mixin(interp!`Multiple params: ${first, " ", last}.`) );

Meta