Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.


You can also do s"$varOne$varTwo" and that concatenates two variables.


Yes, 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.


To 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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: