2    Scala – The REPL

After reading this lesson, you’ll be able to:

  • Execute commands on the Scala REPL
  • Use the REPL to evaluate expressions

The Scala REPL (Read-Eval-Print-Loop) is a development tool to interpret snippets of Scala code. It doesn’t require too much setup or infrastructure, and it is going to be a crucial tool in learning Scala: you’ll be able to play and experiment with the language by typing and evaluating fragments of code. In the next lesson, you’ll install SBT – a tool to build and run properly structured programs.

2.1           The REPL Installation

In this section, you’ll learn how to install the Scala REPL on Linux, macOS, and Windows using a package manager. Alternatively, you can also download Scala binaries from its official website: visit https://scala-lang.org/download and its “Download the Scala binaries” section for instructions on how to do this.

First, you need to check that you have installed Java 8+ JDK. Open the terminal and type the command java -version to check your java version. You should see a message similar to the following:

$ java –version
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)

If you need to install or upgrade your JDK, you can find its binaries with installation instructions at http://www.oracle.com/technetwork/java/javase/downloads/index.html.

2.2           The REPL Commands

2.3           The REPL Code Evaluation

2.4           Summary