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 book lessons.
Make sure the following tools are installed:
- JDK 8+
- sbt
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
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.
-
UNIT 0: HELLO SCALA!
-
UNIT 1: THE BASICS
-
UNIT 2: OBJECT-ORIENTED FUNDAMENTALS
-
UNIT 3: HTTP SERVICE
-
UNIT 4: IMMUTABLE DATA AND STRUCTURES
- LESSON 19: Case classes to structure our data
- LESSON 20: Higher Order Functions
- LESSON 21: What is Purity?
- LESSON 22: Option
- LESSON 23: Working with Option: map and flatMap
- LESSON 24: Working with Option: for-comprehension
- LESSON 25: Tuple and Unapply
- LESSON 26: CAPSTONE 4 - Rock, Paper, Scissors, Lizard, Spock!
-
UNIT 5: LIST
-
UNIT 6: OTHER COLLECTIONS AND ERROR HANDLING
-
UNIT 7: CONCURRENCY
-
UNIT 8: JSON (DE)SERIALIZATION