Object Statement

Makes a singleton object.


[ @Shared ] _
Object object_name [ Is base_class ] [ Does trait_list ]
    [ statements ]
End [ Object ]


Optional modifier specifies that the object can have a small scope, but its lifetime continues until the program completes.
Mandatory name for the object.
Optional name of a class from which the object inherits methods and properties.
Mandatory after Does, one or more traits, with a comma between each. See Does Clause (Traits) for more information.
Optional declarations and control statements.
Completes the statement. You can also use End Object
You can change this part of the syntax. See @Option Directive for more information.


Object operates almost the same as Class and New put together. The result is an object called a singleton. The object is the only instance of its class, and you cannot make a copy of it.

You make an object almost the same as a class. It is divided into two parts – data and code.

All members of an object are shared. Thus it is not necessary to declare a member with @Shared.

Permitted members

You can make most of the same members in Object that you can in Class. But you cannot use Constructor and Destructor. A list of permitted members follows.


Object without state

Object Singleton
    Method Speak
        PrintLine "I'm a singleton"
    End Method
End Object


See also