-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.guano
104 lines (82 loc) · 1.86 KB
/
main.guano
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import sqrt as srt;// from math;
// import {sqrt as srt, sqrt} from math; is valid
// import {sqrt as srt, *} from math; renames srt, and imports the rest as normal.
import math;
// import math as mathematics; is valid
// import * from math;
pub class Animal {
pub animal_name: string;
}
impl Animal {
pub fun get_animal_name() -> string {
return this.animal_name;
}
pub fun init(name: string) {
this.animal_name = name;
// <<;
// < <;
// 0x100
// 0b100
// 011000
}
pub fun init(first_part: string, second_part: string) {
this.animal_name = first_part + second_part;
}
}
impl AmbiguousEntity on Animal {}
pub proto AmbiguousEntity {
fun has_name -> boolean {
return this is NamedEntity;
}
}
pub proto NamedEntity: AmbiguousEntity {
fun retrieve_name() -> string;
fun change_name(name: string) -> string;
}
pub class Person: Animal {
pub name: string;
pub age: uint;
}
impl Person {
pub fun init(name: string, age: uint) {
this.super("Human"); // calls the superclasses constructor
this.name = name;
this.age = age;
}
veto fun get_animal_name -> string {
return "I am a human";
}
}
impl AmbiguousEntity on Person {
fun has_name -> boolean {
return true;
}
}
impl NamedEntity on Person {
fun retrieve_name -> string {
return this.name;
}
fun change_name(name: string) -> string {
let old = this.retrieve_name();
this.name = name;
return name;
}
}
fun main {
let people = [
Person("Noah", 17),
Person("Gabby", 14),
Person::init("Rebecca", 36),
Person::init("Jairo", 41)
];
}
fun sqrt_2 -> float {
return math::sqrt(2.0);
}
fun other_sqrt_2 -> float {
return srt(2.0);
}
/// Reee
/*!
Reeeeee
*/