In python REPL I can do things like:
>>> [1,2,3,4]
[1, 2, 3, 4]
>>> sum(_)
10
In clojure REPL I can do this:
user=> "Hello!"
"Hello!"
user=> *1
"Hello!"
Is there is something like this in Scala REPL?
We can start Scala REPL by typing scala command in console/terminal.
Scala REPL is a command-line tool for the expression, evaluation, and execution of small code snippets. The acronym REPL stands for “Read-Evaluate-Print-Loop”. Similar to Java Shell, Scala REPL is very useful to newcomers and to those who want to experiment with new libraries or language features.
The Scala REPL (“Read-Evaluate-Print-Loop”) is a command-line interpreter that you use as a “playground” area to test your Scala code.
Yes, you can use dot notation to refer to the last result:
scala> List(1,2,3,4)
res0: List[Int] = List(1, 2, 3, 4)
scala> .sum
res1: Int = 10
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With