Skip to content

Instantly share code, notes, and snippets.

@jasonm23

jasonm23/gist:373562

Created Apr 21, 2010
Embed
What would you like to do?
Singleton pattern
package ${packagename}
{
class ${Singleton}
{
private static var _instance:${Singleton};
public function ${Singleton}(enforcer:SingletonEnforcer)
{
}
public static function getInstance():${Singleton}
{
if(_instance == null)
{
_instance = new ${Singleton}(new SingletonEnforcer());
}
return _instance;
}
}
}
class SingletonEnforcer{}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment