scala> val set = scala.collection.mutable.Set[(Int, Int)]()
set: scala.collection.mutable.Set[(Int, Int)] = Set()
scala> set += (3, 4)
:9: erro
The issue is that it exists in the Set
trait a method +(elem1: A, elem2: A, elems: A+)
and the compiler is confused by it. It actually believes that you try to use this method with 2 Int
parameters instead of using it with a tuple, as expected.
You can use instead: set += (3 -> 4)
or set += ((3, 4))