patterns/singleton/singleton.d

22 lines
345 B
D
Raw Normal View History

2022-12-05 07:38:19 +00:00
module singleton.singleton;
class Singleton
{
private static Singleton singleton;
private this() {}
static Singleton getInstance()
{
if (singleton is null)
singleton = new Singleton;
return singleton;
}
string getDescription()
{
return "I'm a classic Singleton!";
}
}