- changed status to invalid
Operator 'In' into TList<>
Issue #381
invalid
why during the cycles of interactions on tlist with the 'in' operator item free memory?
type
stack = class(TStack<Integer>)
end;
procedure TForm1.btn1Click(Sender: TObject);
var
Lista : TList<stack> ;
var item : stack;
begin
lista := TList<stack>.Create;
item := stack.Create;
item.Push(2);
Lista.Add(item);
for var x in lista do
ShowMessage('interatore') ;
for var x in lista do // <<------ item not exist, in more case generate Exception
ShowMessage('interatore') ;
end;
Thank you.
Comments (1)
-
repo owner - Log in to comment
Because Spring collections are not meant to be used as objects but as interfaces. Use IStack and create via the factory method from TCollections.