如何清除 Scala REPL 中的所有变量
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14292108/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 04:50:13 来源:igfitidea点击:
How to clear all variables in Scala REPL
提问by Plasty Grove
Is there a quick command? I don't want to Ctrl+dand run Scala everytime I want to clear all variables. reset, clear and clean don't work and :helpdoesn't have anything listed
有快捷指令吗?我不想Ctrl+d每次想清除所有变量时都运行 Scala。重置,清除和清洁不起作用,:help并且没有列出任何内容
回答by tenshi
You can use :reset
您可以使用 :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>

