Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,27 @@
|
|||
program Project1;
|
||||
|
||||
type
|
||||
TFuncIntResult = reference to function: Integer;
|
||||
|
||||
// use function that returns anonymous method to avoid capturing the loop variable
|
||||
function CreateFunc(i: Integer): TFuncIntResult;
|
||||
begin
|
||||
Result :=
|
||||
function: Integer
|
||||
begin
|
||||
Result := i * i;
|
||||
end;
|
||||
end;
|
||||
|
||||
var
|
||||
Funcs: array[0..9] of TFuncIntResult;
|
||||
i: integer;
|
||||
begin
|
||||
// create 10 anonymous functions
|
||||
for i := Low(Funcs) to High(Funcs) do
|
||||
Funcs[i] := CreateFunc(i);
|
||||
|
||||
// call all 10 functions
|
||||
for i := Low(Funcs) to High(Funcs) do
|
||||
Writeln(Funcs[i]());
|
||||
end.
|
||||
Loading…
Add table
Add a link
Reference in a new issue