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
Assigned
instead of comparing a pointer withnil
incurs no performance penalty.If the pointer is a function pointer, using
Assigned
makes it clear that you do not intend to call the function and compare its result tonil
. Thus,Assigned
is often used to test function and method pointers.A method pointer has two parts: a code pointer and a data pointer.
Assigned
checks only the most significant word of the code reference: if the high-order word is zero, the method reference isnil
.Assigned
ignores the data pointer.
See Also
Nil Keyword |
Get Delphi in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.