In Intellij Scala Worksheet support, what is the difference between the Run types i.e PLAIN vs REPL ?
Intellij Scala worksheet Run type difference explain
328 Views Asked by MaatDeamon At
2
There are 2 best solutions below
0
On
REPL mode as it says READ EVALUATE PRINT LOOP is kind of interpreter i.e. each expression will be evaluated after to move to next line.. It is generally used to make quick logic checks.
while in worksheet mode you need to make an object or class.. worksheet is the traditional OOPS way like we do in java and whole file is compiled in one go.
Plainevaluation model compiles the whole worksheet in one go before evaluating expressions, whilstREPLevaluation model evaluates each expression on the go before moving to the next one.Adding an expression in
REPLmode evaluates incrementally just that new expression, whilst inPlainmode it would re-interpret the whole worksheet from the beginning.An example where the difference matters is when defining companion objects. Similarly to how in Scala REPL proper we have to use
:pastecommand to define companion, in IntelliJ Scala Worksheet we have to usePlainrun type.