KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
What is the best practice for returning simple objects from functions / procedures in delphi? eg. 2 kinds of code: pass created object as reference , populate object in Proc, destroy it afterwards procedure Proc(var Obj: TMyObject); begin // populate Obj end; O := TMyObject.Create; try Proc(O); // manipulate populated object finally O.Free; end; or get created object as result from function , destroy after manipulation function Func: TMyObj; begin Result := TMyObj.Create; end; O := Func; if O <> nil then begin try // manipulate finally O.Free; end; end;
Tags (comma-separated)
Save Edits
Cancel