← Back to Scala Course | Chapter 1: Setup & Basics | Lesson 3 of 8

The Scala REPL

In this page:

  1. The Scala REPL

The Scala REPL

The Scala REPL (Read-Eval-Print Loop), started by typing scala with no arguments, lets you type expressions and see results immediately, each annotated with its inferred type. It's the fastest way to experiment with small snippets before writing a full program. Every top-level expression you enter is automatically evaluated and printed.

Note: Type :quit (or press Ctrl+D) to exit the Scala REPL.

Example: The Scala REPL

markup
object Main extends App {
  // Simulating what you'd see typing directly into the REPL:
  val result = 2 + 2
  println(s"2 + 2 = $result")
  println("In the REPL, typing '2 + 2' alone would print 'val res0: Int = 4'")
}
🔒

Chapter Quiz — Complete all 8 topics to unlock

0/8 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.