Algebraic data types and class hierarchies are other unifications in the Scala programming language. In other functional languages, there are special ways to create custom algebraic data types. In Scala, this is achieved using class hierarchies and namely
case classes and
objects. Let's see what an ADT actually is, what types there are, and how to define them.
Algebraic data types are just composite types that combine other existing types or just represent some new ones. They have only data and do not contain any functionality on top of this data as normal classes would. Some examples can include the day of the week or a class that represents an RGB color—they have no extra functionality and they just ...