-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.lox
50 lines (39 loc) · 774 Bytes
/
init.lox
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
class LoxClass {
let value = 100;
fn init() {
print(self);
}
fn printVal() {
print(self.value);
}
}
let cls = LoxClass();
cls.printVal();
class Math {
static let CONST = 10;
static let mut variable = 100;
static fn square(n) {
return n * n;
}
static fn printVal() {
print("--------------");
print(Math.CONST);
print(Math.variable);
print("==============");
}
}
class NewMath : Math {
static fn add(a, b) {
return a + b;
}
}
let math = Math();
print(math.square(10));
math.printVal();
print(Math.square(10));
print(Math.square(Math.CONST));
print(Math.variable);
Math.variable = 10;
math.printVal();
NewMath.printVal();
print(NewMath.add(10, 10));