String Interpolation

You can use single quote strings to perform string interpolation, using $ to identify the variables in the string :

var name = "Haxe";
var x = 10;
trace('$name is $x times better than X');
// will trace "Haxe is 10 times better than X"

You can also use {} curly braces to enclose a whole expression :

var name = "Haxe";
var x = 10;
trace('${name.toUpperCase()} is ${x*2} times better than X');
// will trace "HAXE is 20 times better than X"

If you want to output a single $, you can use $$ :

var money = 10;
trace('$money$$and 5');
// will trace "10$and 5"

Note : in Haxe 2.09+, single quote strings were not supported, you could instead use a Std.format.

version #15853, modified 2013-01-12 17:19:37 by ncannasse