我在
Scala中尝试以下代码,它来自
An Overview of the Collections API.
import collection._ scala> Traversable(1,2,3) res5: Traversable[Int] = List(1,3) scala> Iterable("x","y","z") res6: Iterable[String] = List(x,y,z) scala> Map("x" -> 24,"y" -> 25,"z" -> 26) res7: scala.collection.Map[String,Int] = Map(x -> 24,y -> 25,z -> 26) scala> SortedSet("hello","world") res9: scala.collection.SortedSet[String] = TreeSet(hello,world) scala> IndexedSeq(1.0,2.0) res11: IndexedSeq[Double] = Vector(1.0,2.0)
结果表明,这些特征都可以调用其apply方法来创建其实现的实例.但在寻找scala.collection.package对象后,我什么也没找到.我认为必须有某个地方将这些特性与其子类绑定并导入到我的程序中.有人可以解释它在哪里吗?