-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.crdm
More file actions
48 lines (32 loc) · 950 Bytes
/
test.crdm
File metadata and controls
48 lines (32 loc) · 950 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
37
38
39
40
41
42
43
44
45
46
47
48
import "std.io" as io;
public class Person(private name: string, private age: string) {
private:
address: string = "1 High Road";
public:
getAddress() -> string {
return this.address;
}
moveHouse(address: Option<string>) -> void {
this.address = address.value() ?? this.address; // either new address or old address
}
birthday() -> int {
this.age += 1;
return this.age;
}
getName() -> string {
return this.name;
}
}
fn main() -> void {
let p: Person = new Person("Ethan", "17");
io.println("Hello, $1! You live at $2.", p.getName(), p.getAddress());
io.println("Happy $1 birthday, $2!", p.birthday(), p.getName());
// Pointer Arithmetic
let x: int = 1;
let y: *int = #x;
let z: &[int] = &[1, 2, 3];
let a: [int] = [1, 2, 3];
let b: &[fn(int) -> int];
let j123: [[int]] = [[1, 2, 3], [4, 5, 6]];
let c: &[&[int]];
}