Skip to content

Commit b081c7d

Browse files
committed
[update] examples to include anonymous functions and static/instance based class getters.
1 parent 74599b6 commit b081c7d

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

examples/anonymous.ls

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
func ExecuteCallback(callback) {
2+
print "Inside function about to execute callback.";
3+
callback();
4+
}
5+
6+
var callback = func () {
7+
print "hello";
8+
};
9+
10+
ExecuteCallback(func () {
11+
print "Inside of the anonymous function.";
12+
});

examples/getters.ls

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
class GetterDemo {
2+
constructor(name) {
3+
this._name = name;
4+
}
5+
6+
// Instance getter associated only with instances.
7+
name {
8+
return this._name;
9+
}
10+
11+
// Static getter not associated to any instance.
12+
static type {
13+
return "Getter Demo";
14+
}
15+
}
16+
17+
// Access static getter.
18+
print GetterDemo.type;
19+
20+
// Access instance getter.
21+
print GetterDemo("Erik").name;

0 commit comments

Comments
 (0)