You are using the wrong operator.
To add to the collection, you should use :+ , not + . This is due to problems encountered when trying to reflect Java behavior using + to concatenate strings.
scala> var x: List[Int] = List(1) x: List[Int] = List(1) scala> x :+= 2 scala> x res1: List[Int] = List(1, 2)
You can also use +: if you want to add.
source share