如何退出 Scala 2.11.0 REPL?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23232233/
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 06:13:12  来源:igfitidea点击:

How to quit scala 2.11.0 REPL?

scalascala-2.11

提问by Billz

In the last version of scala (2.10.3) REPL, I can type exitto quit from REPL. However, in Scala 2.11.0 this doesn't work.

在 scala (2.10.3) REPL 的最新版本中,我可以输入exit退出 REPL。但是,在 Scala 2.11.0 中这不起作用。

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

scala> exit
<console>:8: error: not found: value exit
              exit
              ^

scala>

回答by Noah

I ran into the same issue on upgrade, just use colon q.

我在升级时遇到了同样的问题,只需使用冒号 q。

:q

Additionally, exitwas deprecated in 2.10.x with sys.exitsuggested instead, so this works as well:

此外,exit在 2.10.x 中已弃用,改为使用sys.exit建议,因此这也适用:

sys.exit

As a side note, I think they did this so you can distinguish between exiting the scala console in sbt and exiting sbt itself, though I could be wrong.

作为旁注,我认为他们这样做是为了区分在 sbt 中退出 scala 控制台和退出 sbt 本身,尽管我可能是错的。

回答by Andreas Neumann

You options to leave the REPL as stated in the answers before are:

您可以选择离开之前答案中所述的 REPL:

:quit
:q

Ctrl + d // Unix
Ctrl + z // Windows

sys.exit

回答by My other car is a cadr

Use the end of file characters. Ctrl-Don linux, Ctrl-Zon Windows.

使用文件结尾字符。Ctrl-D在 Linux 上,Ctrl-Z在 Windows 上。

Using the :helpcommand on my 2.10.3 REPL gets me this hint:

:help在我的 2.10.3 REPL 上使用该命令会得到以下提示:

:quit        exit the interpreter

I don't know whether :quitis still there in 2.11.0 or not though.

我不知道:quit2.11.0 中是否仍然存在。

回答by xring

When I use exitin 2.10.4, I got a warning:

当我exit在 2.10.4 中使用时,出现警告:

warning: there were 1 deprecation warning(s); re-run with -deprecation for details

警告:有 1 个弃用警告;使用 -deprecation 重新运行以获取详细信息

You can use:

您可以使用:

:q
:quit
sys.exit

all of them work in 2.11.x.

它们都在 2.11.x 中工作。

回答by ABC

You can use sys.exit OR :q to exit the shell

您可以使用 sys.exit 或 :q 退出外壳