String Interpolation

New in Haxe 2.09

You can use Std.format to format a string using string interpolation, using $ to identify the variables in the string :

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

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

var name = "Haxe";
var x = 10;
trace(Std.format("${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(Std.format("$money$$x5"));
// will trace "10$x5"

version #11647, modified 2011-10-12 23:39:24 by ncannasse