Name
Assigned Function
Syntax
function Assigned(P: Pointer): Boolean; function Assigned(Obj: TObject): Boolean; function Assigned(Method: TMethod): Boolean;
Description
The Assigned
function returns True if the argument
is not nil; it returns False if the argument is
nil. Assigned is not a real
function.
Tips and Tricks
The argument can be a pointer, an object reference, or a method.
Calling
Assignedinstead of comparing a pointer withnilincurs no performance penalty.If the pointer is a function pointer, using
Assignedmakes it clear that you do not intend to call the function and compare its result tonil. Thus,Assignedis often used to test function and method pointers.A method pointer has two parts: a code pointer and a data pointer.
Assignedchecks only the most significant word of the code reference: if the high-order word is zero, the method reference isnil.Assignedignores the data pointer.
See Also
| Nil Keyword |
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access