Is there a way to refer to a dinamicaly created object in "with" segment to let's say pass this object somewhere else?
I have a simple code like this
var
someObject: TSomeObject;
begin
someObject := TSomeObject.Create;
try
someObject.someProperty := 1;
SomeOtherProcedure(someObject);
finally
someObject.Free;
end;
end;
there is a variable that is being passed to SomeOtherProcedure. Now I am trying to drop someObject variable and use "with" segment to have something like this
begin
with TSomeObject.Create do
try
someProperty := 1
SomeOtherProcedure( < what goes here ?? > );
finally
Free;
end;
end;
I do not want to have something like
var
someObject: TSomeObject;
begin
someObject := TSomeObject.Create;
with someObject do
(...)
Is this even possible to refer to an object that is being created in "With"?
Thanks!