3 ms·
You can also do s"$varOne$varTwo" and that concatenates two variables.
by edko 10y ago
You can also do s"$varOne$varTwo" and that concatenates two variables.
- kbenson 10y agoYes, as an alternate syntax, interpolation works well to disambiguate your intent, which supports my point. It's really just a highly specialized form of a different operator, which says I work on strings, so anything I see that isn't a string coerce to a string. For example, in Perl $varOne . $varTwo Is entirely equivalent to "$varOne$varTwo" The question is why Scala chose to use + when it had other, non-ambiguous options, like above.
- airless_bar 10y agoTo be more familiar to Java developers. There are some thoughts about migrating people away from + toward string interpolation. But automated conversion tools are required before this can happen.