In addition to @alexey-romanov answer
In general ++ is used for generating a new data structure.
We can use it in following forms(with example) :-
1. ++
++ is used to yield a new data structure.
Ex :-
val digits2=Map("One" -> 1,"Two" -> 2)
val digits = Map[String,Int]() ++ digits2
digits: scala.collection.immutable.Map[String,Int] = Map(One -> 1, Two -> 2)
OR
Note:- Below digits4's map is having a key One with a value 5
val digits4=Map("One" -> 5,"Three"-> 3,"Four" -> 4)
val Combined1 = digits2 ++digits4
Combined1: scala.collection.immutable.Map[String,Int] = Map(One -> 5, Two -> 2, Three -> 3, Four -> 4)
2. ++:
This operator does same as above ++ does. When used on two operands.
val Combined2 = digits2 ++:digits4
Combined2: scala.collection.immutable.Map[String,Int] = Map(One -> 5, Two -> 2, Three -> 3, Four -> 4)
3. ++= and ++=:
they do similar operations on other data types defined in http://www.scala-lang.org/api/current/index.html#index.index-_.
val buf = new StringBuilder
buf += 'a'
buf ++= "bcdef"
println("buf : "+buf)
results
buf : abcdef
val buf1 = new ArrayBuffer[String]()
buf1 +="a"
val buf2 = new ArrayBuffer[String]()
buf2 +="bcde"
val buf3 = buf1 ++=: buf2
println("buf3 = "+buf3)
results :- buf3 = ArrayBuffer(a, bcde)