Defines a singleton object.
[ [Shared] ] Object #object_name [ Is class_name ] [ Does trait_name ]... [ statements ] End [ Object ]
- Necessary object reference
- Optional name of a class from which the object inherits methods and properties.
- Optional, repeatable
- Necessary after Does. For details, see Does Clause (Traits).
- Completes the statement. You can also use End Object
The Object statement combines the functionality of the Class statement and New statement. The result is an object called a singleton. The object is the only instance of its class, and cannot be copied. Thus the Object statement enforces the Singleton design pattern.
You define an Object in a way very similar to a Class statement. Just like a Class statement, an Object is divided into two sections – data and code.
A major property of the Object statement is that all members are implicitly Shared. Thus it is redundant to declare any member with the Shared modifier.
You can define mostly the same members in an Object that you can in a Class. The only exceptions are the Constructor statement and Destructor statement. A list of the allowed members follows.