I want to create a set of integers called IntSet
. IntSet
is identical to Set[Int]
in every way except that its toString
funct
scala> import scala.collection.mutable
import scala.collection.mutable
scala> def IntSet(c: Traversable[Int]): mutable.Set[Int] = new mutable.SetProxy[Int] {
| override val self: mutable.Set[Int] = mutable.HashSet(c.toSeq :_*)
| override def toString = mkString(",")
| }
IntSet: (c: Traversable[Int])scala.collection.mutable.Set[Int]
scala> IntSet(1 to 3)
res0: scala.collection.mutable.Set[Int] = 1,2,3