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 a LINQ Where clause:

var results = data.Where(p => p.Items == 0);

The Where() clause could receive many different predicates which gives it considerable flexibility.

Passing a method into another method is also seen when implementing the Strategy design pattern. For example, various sorting methods could be chosen from and passed into a Sort method on an object depending on the requirements at run-time.

Feedback about page:

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



Table Of Contents