Using lambda functions in Delphi

I have a question about lambda function.

In the example below, is this a lambda function in Delphi?

var
  Lambda: TFunc<Integer, Integer>;
begin
  Lambda:= function(ANumber: Integer) : Integer
           begin
             Result:= ANumber * ANumber;
           end;


   ShowMessage(Lambda(2).ToString());
   ShowMessage(Lambda(4).ToString());
end;

thank

+4
source share
1 answer

In Delphi terminology, which is an anonymous function. In some languages, they are known as lambda functions. So yes, this is a Lambda function.

This is Wikipedia on the topic: http://en.m.wikipedia.org/wiki/Anonymous_function

+9
source

All Articles