Search code examples
haxe

String substitution/String formating in Haxe


A feature that - most often - is quite helpful is string substitution/string formating. For example one of the following commands:

"Hi my name is %s and I'm %s years old" % ("Derp", 12)

or

"Hi my name is {0} and I'm {1} years old".format("Derp", 12)

will be evaluated to

Hi my name is Derp and I'm 12 years old

in python. Is there a (predefined) way to do something similar in Haxe?


Solution

  • Yup.

    It's called String Interpolation in Haxe.