Intellij Scala工作表运行类型差异说明 [英] Intellij Scala worksheet Run type difference explain
问题描述
在Intellij Scala工作表支持中,运行类型(即PLAIN与REPL)之间有什么区别?
In Intellij Scala Worksheet support, what is the difference between the Run types i.e PLAIN vs REPL ?
推荐答案
Plain
评估模型先评估整个工作表,然后再评估表达式,而 REPL
评估模型进行评估在移动到下一个表达式之前,随时随地使用每个表达式.
Plain
evaluation model compiles the whole worksheet in one go before evaluating expressions, whilst REPL
evaluation model evaluates each expression on the go before moving to the next one.
在 REPL
模式下添加表达式只会对该新表达式进行增量评估,而在 Plain
模式下,它将从头开始重新解释整个工作表.
Adding an expression in REPL
mode evaluates incrementally just that new expression, whilst in Plain
mode it would re-interpret the whole worksheet from the beginning.
其中一个差异很重要的示例是定义伴随对象时.与在Scala REPL中正确使用方式类似,我们必须使用 :paste
命令来定义随播广告,IntelliJ Scala工作表,我们必须使用 Plain
运行类型.
An example where the difference matters is when defining companion objects. Similarly to how in Scala REPL proper we have to use :paste
command to define companion, in IntelliJ Scala Worksheet we have to use Plain
run type.
这篇关于Intellij Scala工作表运行类型差异说明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!