A higher-order function is a function does at least one of these:
- It accepts a function as an argument
- It returns a function as a result
Kotlin supports higher-order functions. In the following example, calculateCost()
accepts a function as an argument, and getDiscount()
returns a function as a result.