chapter twenty
Lesson 20 High Order Functions
After reading this lesson, you will be able to:
- Define functions that have functions as parameters
- Implement functions that return functions
- Build powerful abstractions that remove code duplication
In Scala functions are first class citizens: you can use them as parameters or return them as the result of some computation. “High order functions” are functions that accept other functions as parameters, or that return functions, or both. Their use allows you to create powerful abstractions that reduce code duplication and increase the reusability of your programs. In the capstone, you’ll use high order functions to extract information on the winner of the game “Paper, Rock, Scissors, Lizard, Spock!”.