Last active
August 25, 2016 07:14
-
-
Save frontdevops/324baf351e1e98b25f0861923978244e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Singleton { | |
protected static _instance :Singleton = new Singleton; | |
protected foo :number = 123; | |
constructor() { | |
if (Singleton._instance) { | |
throw new Error("Instantiation failed: "+ | |
"use Singleton.getInstance() instead of new."); | |
} | |
} | |
public static getInstance() :Singleton { | |
return Singleton._instance; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment