Skip to content

Instantly share code, notes, and snippets.

@matschaffer
Created April 29, 2009 13:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matschaffer/103755 to your computer and use it in GitHub Desktop.
Save matschaffer/103755 to your computer and use it in GitHub Desktop.
MyClass = function() {
this.foo = "foo"
};
MyClass.prototype = {
set foo(v) {
print("sorry, I don't wanna set foo with " + v);
},
get foo() {
return "not really foo";
}
}
obj = new MyClass();
print(obj.foo);
obj.foo = "bar";
/* Output is
* sorry, I don't wanna set foo with foo
* not really foo
* sorry, I don't wanna set foo with bar */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment