HaxeFoundation / haxe.org-comments

Repository to collect comments of our haxe.org websites
2 stars 2 forks source link

[haxe.org/manual] String Interpolation #99

Open utterances-bot opened 2 years ago

utterances-bot commented 2 years ago

String Interpolation - Haxe - The Cross-platform Toolkit

Haxe is an open source toolkit based on a modern, high level, strictly typed programming language.

https://haxe.org/manual/lf-string-interpolation.html

chikega commented 2 years ago

It may be worth mentioning that any apostrophes have to be escaped such as:

trace('Gary\'s GPA is $gpa');
Simn commented 2 years ago

This isn't really related to string interpolation, but we could cross-reference https://haxe.org/manual/std-String-literals.html

chikega commented 2 years ago

Haxe is the rare bird that converts to single quotations, from double quotations, in order to effectuate string interpolation which potentially can give rise to the use of escaping apostrophes.

daverave1212 commented 2 years ago

I discovered you can use interpolation with custom classes objects by implementing the "toString()" function. When you do something like 'x is $x', this actually seems to call 'x is ${x.toString()}'