19 lines
376 B
Text
19 lines
376 B
Text
-- Singleton.pluto --
|
|
|
|
local instance = nil
|
|
|
|
class singleton
|
|
static function getInstance()
|
|
if !instance then new singleton() end
|
|
return instance
|
|
end
|
|
|
|
function __construct()
|
|
assert(!instance, "The singleton instance already exists.")
|
|
instance = self
|
|
end
|
|
|
|
function print()
|
|
print("Hello, I'm a singleton.")
|
|
end
|
|
end
|