What delphi function asserts that an object is not nil?
Like knight_killer pointed out above, you use the Assert()
function, asserting that Assigned(obj)
is true
. Of course, like in most compiled languages, assertions are not executed (or even included in the compiler output) unless you've specifically enabled them, so you should not rely on assertions for release mode builds.
You can, of course, simply check against nil
, a la Assert(obj <> nil)
. However, Assigned()
produces the exact same compiler output and has the added benefit that it works on pointers to class methods too (which are in reality a pair of pointers, one to the method, and the other one to the class instance), so using Assigned()
is a good habit to pick up.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With