This part of the book is all about the differences between Scala and Java. There are plenty of language features in Scala that don’t have an obvious analog in Java. In this part, we’ll take a closer look at some of those and explore what Scala can give us over Java.
Specifically, we’ll explore some of the language features that make writing Scala more expressive and we’ll look at some of the more functional programming idioms that Scala is so well know for.
Scala offers several features that make writing code more concise. As well as some we’ve already seen, it provides mechanisms to:
apply
method.update
method.Scala also offers pattern matching; we’ll look at the unapply
method and its role in pattern matching.
We’ll also look at some of functional programming aspects of Scala.
map
, flatMap
).Option
class as a way of avoiding null checks.This only scratches the surface of functional programming but I hope that this part of the book will give you a useful head start when it comes to Scala and functional programming.