SINGLETON:
Factor handbook > The language > Objects > Classes > Singleton classes

Next:SINGLETONS:


Vocabulary
syntax

Syntax
SINGLETON: class


Inputs and outputs
classa new singleton to define


Word description
Defines a new singleton class. The class word itself is the sole instance of the singleton class.

Examples
USING: classes.singleton kernel io ; IN: singleton-demo USE: prettyprint SINGLETON: foo GENERIC: bar ( obj -- ) M: foo bar drop "a foo!" print ; foo bar
a foo!


See also
define-singleton-class

Definition