In this workshop we cover collections, Option
, Try
and higher-order functions on these classes.
Please, read through the material in the following order, before proceeding to the assignments.
- higher-order functions - getting to know what a higher-order function is, how it looks and how you use it
- some basic higher-order functions in Scala
Option
- introducing theOption
type as a better alternative tonull
valuesflatMap
and for-comprehension onOption
- for-comprehension on
List
Try
- introducting theTry
type as the way of handling errors in a functional way- other collections - conversion between Java and Scala collections and some more operators
- Scala API - Documentation of the Scala API. Make sure you have this page open in your browser all the time!
- Monads in pictures - The
map
andflatMap
operators that we used in this workshop are formalized in the concepts ofFunctor
andMonad
. This is a good post to understand what these do and howmap
andflatMap
are supposed to behave. - Learn You a Haskell for Great Good - For the ones that are really interested in functional programming, this book is the place to start!
- Scala Monads - A good starter explanation of the
Option
,Try
andList
monads that shows remarkable similarities with our explanation 😜...