Isn't that unambiguous since I don't use m. + =?
No, it is not, because parentheses can always be used when there are several arguments. For example:
List(1, 2, 3) mkString ("<", ", ", ">")
So you may ask, what are some of the options? Well, the Scala API document is your friend (or mine, at least), so I present to you:
scala> val m = scala.collection.mutable.Map[String, Int]() m: scala.collection.mutable.Map[String,Int] = Map() scala> m += (("foo", 2), ("bar", 3)) res0: m.type = Map(bar -> 3, foo -> 2)
In other words, += accepts vararg.
Daniel C. Sobral
source share