Skip to content

Commit

Permalink
rename instance variable
Browse files Browse the repository at this point in the history
  • Loading branch information
torokmark authored Dec 5, 2017
1 parent fb03481 commit 35ac2d2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions singleton/src/singleton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ namespace Singleton {
class Singleton {
// A variable which stores the singleton object. Intially,
// the variable acts like a placeholder
private static __singleton: Singleton = null;
private static singleton: Singleton = null;
// private constructor so that no instance is created
private constructor() {
}
// This is how we create a singleton object
public static getInstance(): Singleton {
// check if an instance of the class is already created
if (this.__singleton == null) {
if (this.singleton == null) {
// If not created create an instance of the class
// store the instance in the variable
this.__singleton = new Singleton();
this.singleton = new Singleton();
}
// return the singleton object
return this.__singleton
return this.singleton
}
}
}

0 comments on commit 35ac2d2

Please sign in to comment.