Chapter 3. Unification

Being able to understand and write good code in Scala requires developers to be familiar with the different concepts of the language. In a few places so far, we have mentioned that Scala is really expressive. To some extent, this is because there are a number of programming concepts that have been unified. In this chapter, we will focus on the following concepts:

  • Functions and classes
  • Algebraic data types and class hierarchies
  • Modules and objects

Functions and classes

In Scala, every value is an object. Functions are first class values, which also makes them objects of their respective classes. The following figure shows the Scala unified type system and how this is achieved. It is adapted from http://www.scala-lang.org/old/sites/default/files/images/classhierarchy.png ...

Get Scala Design Patterns now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.