An Anonymous Method Variable

Once you have an anonymous method type you can, in the simplest cases, declare a variable of this type, assign a type-compatible anonymous method, and call the method through the variable:

procedure TFormAnonymFirst.btnSimp1eVarClick(

Sender: TObject); var anIntProc: TIntProc; begi n anIntProc :=

procedure (n: Integer) begi n

Memo1.Lines.Add (IntToStr (n)); end; anIntProc (22); end;

Notice the syntax used to assign an actual procedure, with in-place code, to the variable. This is something never seen in Pascal in the past.

Was this article helpful?

0 0
Project Management Made Easy

Project Management Made Easy

What you need to know about… Project Management Made Easy! Project management consists of more than just a large building project and can encompass small projects as well. No matter what the size of your project, you need to have some sort of project management. How you manage your project has everything to do with its outcome.

Get My Free Ebook


Post a comment