快速scala编译器无法编译可变的TreeMap

时间:2017-01-31 07:07:12

标签: scala

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编译相同的话就会成功编译。

1 个答案:

答案 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混淆。