If I create a Set
in Scala using Set(1, 2, 3)
I get an immutable.Set
.
scala> val s = Set(1, 2, 3)
s: scala.collection.immutable.Set[Int] = Set(1, 2, 3)
Q1: What kind of Set is this actually? Is it some hash-set? What is the complexity of look-ups for instance?
Q2: Where can I read up on this "set-creating" method? I thought that it was the apply
method but the docs says "This method allows sets to be interpreted as predicates. It returns true, iff this set contains element elem."
Similarly, if I create a List
using List(1, 2, 3)
, I get
scala> val l = List(1, 2, 3)
l: List[Int] = List(1, 2, 3)
scala> l.getClass
res13: java.lang.Class[_] = class scala.$colon$colon
Q3: Again, what do I get? In this case I can't even immediately tell if it's mutable or not, since it's not even part of the scala.collection
-package. Why does this live in the scala
package?
Q4: Where in the API can I read about this "list-creating" method?