Skip to content

Instantly share code, notes, and snippets.

@rednaxelafx
Created November 15, 2011 08:48
Show Gist options
  • Save rednaxelafx/1366484 to your computer and use it in GitHub Desktop.
Save rednaxelafx/1366484 to your computer and use it in GitHub Desktop.
TJS2 examples. Just a reminder. docs: http://devdoc.kikyou.info/tvp/docs/tjs2doc/contents/
class Foo {
var val;
property p {
getter {
return val;
}
setter(v) {
this.val = v;
}
}
function finalize() {
System.inform("finalize(): " + this);
}
}
var foo = new Foo();
foo.p = 123;
System.inform(foo);
System.inform(typeof foo);
System.inform(foo.p);
// var foo.bar = 'quux'; // can't do this
foo.bar = 'quux'; // can dynamically add members
System.inform(foo.bar);
(function () {
System.inform(this.bar);
} incontextof foo)();
delete foo.bar; // can dynamically remove members
// (function () {
// System.inform(this.bar);
// } incontextof foo)(); // member not found, exception
invalidate foo; // deterministically destroy object (like C++'s delete operator)
System.inform(isvalid foo); //=> 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment