Singleton: Difference between revisions
m
→{{header|Wren}}: Changed to Wren S/H
(→{{header|Java}}: Add Enum as a singleton) |
m (→{{header|Wren}}: Changed to Wren S/H) |
||
Line 2,337:
In practice, it's unlikely anyone would bother; they'd just create a class with static methods and/or fields only which is effectively a singleton as there's only ever a single instance of a static field.
<syntaxhighlight lang="
// Returns the singleton. If it hasn't been created, creates it first.
static instance { __instance == null ? __instance = Singleton.new_() : __instance }
|