Fun with anonymous methods – using higher-order functions

Since Version 2009, the Delphi language (or better, its Object Pascal dialect) supports anonymous methods. What's an anonymous method? Not surprisingly, an anonymous method is a procedure or a function that does not have an associated name. An anonymous method treats a block of code just like a value so that it can be assigned to a variable, used as a parameter to a method or returned by a function as its result value. In addition, an anonymous method can refer to variables and bind values to the variables in the context scope in which the anonymous method is defined. Anonymous methods are similar to closures defined in other languages such as JavaScript or C#. An anonymous method type ...

Get Delphi Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.