-
-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathuser_math.ai
More file actions
36 lines (27 loc) · 663 Bytes
/
user_math.ai
File metadata and controls
36 lines (27 loc) · 663 Bytes
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
print("loaded math.ai");
pub const PI = 3.14;
pub fn add(x: int, y: int) -> int { // Available as math.add
return x + y;
}
pub fn sub(x: int, y: int) -> int { // Available as math.add
return x - y;
}
print(add(1,2));
print(PI);
pub class A {
fn test() {
print("test from A");
}
}
print("end of math.ai");
let global_variable = "abc";
if len(global_variable) > 1 {
let local_variable = "xyz";
print("I can access global variable:", global_variable);
}
// local variable is inaccessible outer of local scope,
// this print statement would
// print(local_variable);
const PI = 3.14;
print(PI); // print 3.14
PI = 3.1415; //