Talk:Anonymous Methods in Delphi

From RAD Studio
Jump to: navigation, search

The following example needs to be corrected:

function MakeAdder(y: Integer): TFuncOfInt;

 begin
   Result := { start anonymous method } function(x: Integer) //<<---- error here
     begin
       Result := x + y;
     end; { end anonymous method }
 end;

Where

type

 TFuncOfInt = reference to function(x: Integer): Integer;


The incorrect line should read

   Result := { start anonymous method } function(x: Integer) : Integer

Response

After verification of the correction, I incorporated your suggestion. Many thanks -- KrisHouser 16:32, 5 March 2010 (PST)

Suporting Material About Anonymous Methods

http://delphi.fosdal.com/2008/08/anonymous-methods-when-to-use-them.html