Destructor Method

Executed automatically when a class goes out of scope.

Syntax
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 REALbasic doesn't do 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 REALbasic clean them up for you.

# See Also

Constructor method; Destructors Can't Have Parameters error.