System.Assigned is more flexible and has less edge cases than a normal nil
comparison. In particular:
Assigned can be used to test if object procedures are assignedAssigned always checks the assignment of function references themselves -
nil comparisons may call the function and check the assignment of its return value
Assigned is clearer and more self-documentingReplace the nil comparison with a call to Assigned:
procedure LogAssigned(MyObj: TObject);
begin
if MyObj <> nil then begin
Writeln('Object is assigned');
end;
end;
procedure LogAssigned(MyObj: TObject);
begin
if Assigned(MyObj) then begin
Writeln('Object is assigned');
end;
end;