Summary
In this chapter, we looked at two very important concepts in Scala, namely pattern matching and partial functions. We saw many examples where pattern matching comes handy, and its application to get the double dispatch works for us. We implemented the chain of responsibilities design pattern in Java. Partial functions are a very useful concept in their own right, and we saw how to implement the chain of responsibilities using partial functions in Scala. Along the way, we looked at the collect functions. The stage is set now for you to get into the thick of functional programming. We have already briefly touched upon the theme of composition and how to create a pipeline. In the upcoming chapter, we will see various functional combinators and put them to use in order to compose large behavior from smaller parts. So, tighten your seat belts, and let's fly into the functional wonderland!