Concept

Destructor


Description

A special method that is called automatically when an object goes out of scope.

Usage

Destructor

Notes

The Destructor method is called automatically, so you would never call it yourself. It takes no parameters and does not return a value.

Destructors are typically used to do any "clean up" that is not done for you automatically. If it exists, a class's Destructor is called automatically when an instance of the class is deleted or goes out of scope — for example, when the user closes the window.

To create the Destructor for a custom class, add a method to the class and name it "Destructor".

Destructors are called when the last reference to an object is removed, even if execution is in a Destructor for another object. Note that this means you can cause a stack overflow if your Destructor triggers other destructors in a deep recursion. However, such overflow will not happen as long as properties of the object are being cleaned up automatically. So, it is generally preferable to not set properties to Nil in your Destructor, but instead let them be cleaned up for you.

Unlike a Constructor or other methods, the Destructor in a subclass does not override its superclass Destructor. Normally you would not call Super.Destructor in your subclass' Destructor since this will cause the superclass' Destructor to fire twice.

Compatibility

All project types on all supported operating systems.