Perhaps I am barking up the wrong tree (again) but if it is normal practice to have a property typed as a scala.collection.immutable.Set[A]
, then how would you create one of these given a scala.Iterable[A]
? For example:
class ScalaClass {
private var s: scala.collection.immutable.Set[String]
def init(): Unit = {
val i = new scala.collection.mutable.HashSet[String]
//ADD SOME STUFF TO i
s = scala.collection.immutable.Set(i) //DOESN'T WORK
s = scala.collection.immutable.Set(i toSeq : _ *) //THIS WORKS
}
}
Can someone explain why it is necessary to create the immutable set via a Seq
(or if it is not, then how do I do it)?