object Test {
var returnData: scala.collection.mutable.TreeMap[Char, Char] = scala.collection.mutable.TreeMap[Char, Char]()
}
如果我用fsc编译这个类(使用scala 2.12.1),那么它会给我一个错误:
object TreeMap is not a member of package scala.collection.mutable
var returnData: scala.collection.mutable.TreeMap[Char, Char] = scala.collection.mutable.TreeMap[Char, Char]()
但是如果我用scalac编译相同的话就会成功编译。
答案 0 :(得分:0)
与Scala 2.12.1一起工作正常
$ scala -version
Scala code runner version 2.12.1 -- Copyright 2002-2016, LAMP/EPFL and Lightbend, Inc.
$ cat > script.scala
object Test {
var returnData: scala.collection.mutable.TreeMap[Char, Char] = scala.collection.mutable.TreeMap[Char, Char]()
}
$ fsc script.scala
$ ls
script.scala Test.class 'Test$.class'
您必须将设置与Scala 2.11.x混淆。