O'Reilly logo

Scala Functional Programming Patterns by Atul S. Khot

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 9. Higher Order Functions

In the last chapter, we saw how the use of combinators simplifies code. We just have to pass in functions and not worry about the boilerplate of writing loops or creating pipelines.

The idea behind all this is that higher order functions can take other functions as parameters, return a function as a result, or do both. In Scala, as we already know, functions are first-class citizens. This is a rather neat idea, as we will soon see.

In this chapter, we will start with the strategy pattern and see the Java implementation. Then, we will change gears and see how this pattern is really not needed when you talk about Scala. This is largely the effect of being able to send across functions and function literals. Once we ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required