Using the REPL

Quite a few languages provide a REPL—read-eval-print loop—a tool that’s a convenient way to key in snippets of code and interactively see the code come to life immediately. In addition to executing code snippets, REPLs often provide details that are not easily accessible at runtime. That makes REPL a special tool for experimentation and also to learn how the language infers types for variables and functions.

The command-line shell named scala is the REPL for Scala and it’s the quickest way to try out the language. Using this tool we can start playing with small code snippets. This is not simply a learning tool; it comes in handy during development of large applications as well. You can quickly try out some code ideas—micro prototyping—in ...

Get Pragmatic Scala now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.