Skip to content

Instantly share code, notes, and snippets.

@H2CO3
Created June 22, 2014 23:33
Show Gist options
  • Save H2CO3/bdf0f4326bb72e961241 to your computer and use it in GitHub Desktop.
Save H2CO3/bdf0f4326bb72e961241 to your computer and use it in GitHub Desktop.
//
// WARNING:
// a "Greeter" class is a typical BAD example,
// an anti-pattern. You shouldn't be making this
// a class IRL. I've only come up with this
// example because I've run out of creative sauce.
//
function Greeter(msg) {
var self = {
"message": msg,
"timestamp": time(),
"sayHello": function() {
print("hello from object ", self, " at ", self.timestamp, ": ", self.message);
}
};
return self;
}
var g1 = Greeter("Hello world!");
// sleep(1);
for var i = 0; i < 30000000; i++ {}
var g2 = Greeter("I'm late!");
g1.sayHello();
g2.sayHello();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment