20 Higher 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
Functions are first-class citizens in Scala: you can use them as parameters or return them as the result of some computation. “Higher 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 duplication and increase the reusability of your code. In the capstone, you’ll use higher order functions to extract information on the winner of the game “Paper, Rock, Scissors, Lizard, Spock!”.