如何清除Scala REPL中的所有变量

Pla*_*ove 27 scala

有快速命令吗?我不想Ctrl+d和运行斯卡拉每次我要清除所有变量.重置,清除和清洁不起作用,:help没有列出任何内容

ten*_*shi 43

您可以使用 :reset

Welcome to Scala version 2.10.0-RC2 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_37).
Type in expressions to have them evaluated.
Type :help for more information.

scala> val a = 1
a: Int = 1

scala> val b = 3
b: Int = 3

scala> :reset
Resetting interpreter state.
Forgetting this session history:

val a = 1
val b = 3

Forgetting all expression results and named terms: $intp, a, b

scala>
Run Code Online (Sandbox Code Playgroud)

  • 谢谢!我刚刚意识到我正在使用 Scala 2.9.2,知道我可以在那里使用什么吗?`:reset` 不起作用 (2认同)