:Scala REPL中的import命令

时间:2013-09-26 06:49:27

标签: scala

Scala in Action 一书中说,在Scala REPL中使用:import 命令,我们将看到:

scala> :imports 
    1) import java.lang._       (153 types, 158 terms)
    2) import scala._           (798 types, 806 terms)
    3) import scala.Predef._    (16 types, 167 terms, 96 are implicit)

根据这本书,上面的那些包都是自动导入的。但在我的REPL(Scala 2.10.2)中,它只返回一行:

scala> :imports
     1) import scala.Predef._   (162 terms, 78 are implicit)

有什么不对吗?

1 个答案:

答案 0 :(得分:3)

“Scala in Action”是为2.9写的:

:~$ scala
Welcome to Scala version 2.9.2 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_25).
Type in expressions to have them evaluated.
Type :help for more information.

scala> :imports
 1) import java.lang._             (193 types, 199 terms)
 2) import scala._                 (798 types, 804 terms)
 3) import scala.Predef._          (16 types, 167 terms, 96 are implicit)