Add new example scripts.

This commit is contained in:
Stephen Chung
2021-06-07 20:15:06 +08:00
parent c4b3ad7c7b
commit bed5256e2e
4 changed files with 35 additions and 2 deletions

View File

@@ -0,0 +1,12 @@
// This script defines a function that acts as a method
// Use 'this' to refer to the object of a method call
fn action(x, y) {
this = this.abs() + x * y; // 'this' can be modified
}
let obj = -40;
obj.action(1, 2); // call 'action' as method
print(`obj should now be 42: ${obj}`);