Chapter 5Creating Higher-Order Functions in Scala

by Venkat Subramaniam

In Chapter 3, Scala and Functional Style, we discussed higher-order functions in functional programming, and in Chapter 4, Working with Scala Collections, we looked at the higher-order functions in the Scala collections API. In this chapter, we’ll learn how to write our own higher-order functions.

Higher-order functions can accept other functions as parameters, can return functions, and can allow you to create functions within functions. In Scala, these functions that can be passed around are called function values.

You know that in OO programming, classes (or objects) abstract and encapsulate behavior and data. Well, function values also abstract and encapsulate ...

Get Functional Programming: A PragPub Anthology 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.