In the previous lesson, you mastered the operations you can perform on a Map
. In this lesson, you’ll discover a new Scala type called Either
. You can use it to represent a value with one of two possible types. You’ll learn about its structure and how to define an instance for it. You’ll use pattern matching to handle all its possible implementations. You’ll transform its values using the map
and flatMap
function, and you’ll chain multiple values using for-comprehension
. You’ll use the class Either
to validate if your library can accept a given book request in the capstone.