Higher-Order Functions

suggest change

A 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.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents