Reference object instance created using “with” in Delphi
问题 is there a way to reference an object instance that is created using the "with" statement? Example: with TAnObject.Create do begin DoSomething(instance); end; Where DoSomething would use the instance reference as if you were passing an instance from a variable declared reference to the object created. Example: AnObject := TAnObject.Create; Thanks. 回答1: Well, you can use such approach: // implement: type TSimpleMethod = procedure of object; function GetThis(const pr: TSimpleMethod): TObject;