Overloading the string template operator

You’re right, this relation between $ (string templates) and toString doesn’t appear to be explicitly documented (as far as I could find).

The $ inside a string template are shorthand for concatenation, for example “foo $bar baz” can be written as “foo " + bar + " baz”, where the bar expression would be converted to a String via the Object.toString() method.

3 Likes