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 ...

Get Scala Functional Programming 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.