上QQ阅读APP看书,第一时间看更新
REPL
Another tool that we will frequently use is REPL (Read Eval Print Loop). It is often used for quickly evaluating Scala expressions.
From sbt
, we can enter REPL mode with the help of the sbt console
command. Let's try some simple expressions.
Now, we'll look at how to evaluate expressions. Follow these steps to do so:
- Open the
sbt
tool. - Open
REPL
by typing the following command:sbt console
- Type the following expressions and press Enter:
2 + 2
"2" + 2
2 + "2"
(1 to 8).sum
java.time.LocalTime.now()
Please note that we can have an interactive Scala playboard
inside IDE by creating a special file type: a Scala Worksheet. It's useful, but is mainly for demonstration purposes.