Get Programming with Scala

Code, exercises, and answers for the book Get Programming with Scala.

Lessons are grouped per unit. Each lesson is a standalone SBT project and it has the following three packages: listings, quickchecks, trythis.

Have a look at the Table of Contents for links to all the available lessons.

Installation Requirements

Make sure the following tools are installed:

Running the Code

Code Snippets (Scala Worksheets)

Some lessons are simple snippets (files with extension *.sc) also called Scala Worksheets. They can be interpreted interactively from the REPL by IDEs with dedicated Scala support, such as IntelliJ IDEA and ScalaIDE.

If you a using a text editor or your IDE doesn't support Scala Worksheets, start the REPL from SBT:

sbt console

and evaluate the file as follows:

> :load /path/to/file.sc

Executable SBT Programs

Some lessons are fully fleshed-out programs (files with extension *.scala): in order to run them, they need to be compiled. First, navigate to the folder of the lesson you are interested in.

Suppose you want to review the code for lesson 8:

cd unit1/lesson8

Start SBT:

sbt

Compile and run the code:

> run

If a lecture isn't an executable program, please see section on running Scala Worksheets.

Table of Contents