Created
June 22, 2014 23:33
-
-
Save H2CO3/bdf0f4326bb72e961241 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// | |
// 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