I'm pretty new to Scala programming and now trying to understand the exact behavior of the operator +
for the scala.collection.immutable.List. Here is what I wrote:
val _1 = List(1, 2)
println((_1 + "2") foreach print
I couldn't write the following
_1 + 2 //error: expected String
That's clear, because we're trying to execute the +
operator defined within the String
class.
But what is not clear it's why they didn't just override the operator +
for the List
, but instead defined operator ++
for concatenating?
Was there some technical reason for that?
What does that mean?