It appears the toSeq
method in Scala collections returns a scala.collection.Seq
, I could also return a Traversable
or Iterable
but need to convert this to a scala.collection.immutable.Seq
.
Is there an easy way to do this?
Thanks Richard
Use the to
method to convert between arbitrary collection types in Scala 2.10:
scala> Array(1, 2, 3).toSeq
res0: Seq[Int] = WrappedArray(1, 2, 3)
scala> Array(1, 2, 3).to[collection.immutable.Seq]
res1: scala.collection.immutable.Seq[Int] = Vector(1, 2, 3)