In a with
block I need to pass the object which is used with the with
statement as function parameter.
with TMyObject.Create do
begin
//...
MyFunction( (* here I have to pass the created object *) );
//...
end;
The same goal could obviously be achieved as follows:
var
MyObj : TMyObject;
begin
MyObj := TMyObject.Create;
//...
with(MyObj) do
begin
//...
MyFunction(MyObj);
end;
//...
end;
...but I would know if there's a way to simplify my code and get the reference, without declaring the MyObj variable.