3 ms·
Which is good, but interpolation is really just a specialized case of concatenating string literals and variables, not variables to other variables, which is wh
by kbenson 11y ago
Which is good, but interpolation is really just a specialized case of concatenating string literals and variables, not variables to other variables, which is where some ambiguity is introduced.
- edko 11y agoYou can also do s"$varOne$varTwo" and that concatenates two variables.
- kbenson 11y 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 11y 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.