As a more interesting example (with even more surprising syntax), we can pass an anonymous method as parameter to a function. Suppose you have a function taking an anonymous method parameter:
procedure CallTwice (value: Integer;
anlntProc: TIntProc); begi n anlntProc (value); Inc (value); anlntProc (value); end ;
The function calls the method passed as parameter twice with two consecutive integers values, the one passed as parameter and the following one. You call the function by passing an actual anonymous method to it, with directly in-place code that looks surprising:
Sender: TObject); begi n
From the syntax point of view notice the procedure passed as parameter withing parentheses and not terminated by a semicolon. The actual effect of the code is to call the IntToHex with 48 and 49 and the FloatToStr on the square root of 100 and 101, producing the following output:
Was this article helpful?
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.