Hi,
This article is quite clear for me: http://wiki.freepascal.org/for-in_loop
But let say that I have this class:
TMyList = class
private
FList: TList
public
constructor Create;
destructor Destroy;
procedure Add;
procedure Remove;
end;Now I want to do:
for a in MyClass do
begin
end;Can I do this without creating new enumerator? I mean pass enumerator from FList? I'm confused because if I create function:
function TMyClass.GetEnumerator: TListEnumerator
begin
Result := FList.GetEnumerator;
end;... then FList.GetEnumerator create new object
(TListEnumerator.Create(Self)). My question is, where it is freed? Is it freed automatically on runtime after exit from loop? I don't want memory leak
Regards
