Higher-Order Functions
suggest changeA higher-order function is one that takes another function as an argument or returns a function (or both).
This is commonly done with lambdas, for example when passing a predicate to the LINQ Where method:
var results = data.Where(p => p.Items == 0);
Where can receive many different predicates, which gives it considerable flexibility.
Passing a method into another method is also how the Strategy pattern is often expressed. A caller can choose a comparison and pass it to a sort method when the program runs.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents