These are a series of short lessons that cover various topics of the Scala programming language, especially as it relates to functional programming. The lessons are based in part on the open source books by underscore.io along with additional material and examples. They are by no means meant to provide an exhaustive overview the entirety of Scala but rather on what I felt were some of the more practical aspects of the language and of functional programming that you might use your real-world, day-to-day work.
You can jump right in and start going through the lessons starting at the beginning or jumping around to the topics that interest you. I recommend doing this directly from GitHub as it offers pretty good support for markdown and the lessons themselves have navigation links that let you move around pretty easily.
In addition, you can also run all of the code snippets on the REPL. I encourage you to do this and to play around with the examples as it really helps to learn the concepts.
If you want to interact with the examples presented in this project using the REPL, you will need to install SBT. Follow the instructions listed here based on your local environment: https://www.scala-sbt.org/download.html
If you're running on Mac, you can use Homebrew to install SBT:
$ brew install sbt@1
The REPL that I used in the examples throughout the lesson was Ammonite (denoted by
the @
) due to the many improvements that it brings over the standard REPL. It works pretty well for the most part but
once in a while you might run into a few minor quirks.
To set it up on your local environment, simply run the following command:
$ sudo sh -c '(echo "#!/usr/bin/env sh" && curl -L https://github.com/lihaoyi/Ammonite/releases/download/1.3.2/2.12-1.3.2) > /usr/local/bin/amm && chmod +x /usr/local/bin/amm' && amm
You will need to clone a copy of this project as the build.sbt
includes configurations to load the necessary
dependencies that the lessons need:
$ git clone https://github.com/lu4nm3/scala-lessons.git
Afterwards, cd into the root directory and run sbt test:run
to start a new Ammonite shell session:
$ cd scala-lessons/
$ sbt test:run
...
@
Alternatively, you can use the default Scala REPL by running sbt console
from within the root directory of the project
which will start a new shell session:
$ sbt console
...
scala>