// use var with mutable
scala> var set = scala.collection.mutable.Set[Int]()
set: scala.collection.mutable.Set[Int] = Set()
// add one element
scala> set += 1
res0: scala.collection.mutable.Set[Int] = Set(1)
// add multiple elements
scala> set += (2, 3)
res1: scala.collection.mutable.Set[Int] = Set(2, 1, 3)
// notice that there is no error when you add a duplicate element
scala> set += 2
res2: scala.collection.mutable.Set[Int] = Set(2, 6, 1, 4, 3, 5)
// add elements from any sequence (any TraversableOnce)
scala> set ++= Vector(4, 5)
res3: scala.collection.mutable.Set[Int] = Set(2, 1, 4, 3, 5)
scala> set.add(6)
res4: Boolean = true
scala> set.add(5)
res5: Boolean = false
scala 风格:// use var with mutablescala> var set = scala.collection.mutable.Set[Int]()set: scala.collection.mutable.Set[Int] = Set()// add one elementscala> set += 1res0: scala.collection.muta