This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 10.22, “How to Merge Scala Sequential Collections”
You want to join two sequences into one sequence, either keeping all of the original elements, finding the elements that are common to both collections, or finding the difference between the two sequences.
There are a variety of solutions to this problem, depending on your needs:
Scala FAQ: Scala doesn't have the
-- operators; are the some similar operators or methods that I can use instead?
val fields are immutable, they can’t be incremented or decremented, but
var integer fields can be mutated with Scala’s
In Scala there are no
-- operators. You should instead use the
-= operators, as shown below. First the
scala> var i = 1 i: Int = 1 scala> i++ <console>:9: error: value ++ is not a member of Int i++ ^ scala> i += 1 scala> println(i) 2