2019-09-26 03:11:48 +00:00
|
|
|
const (
|
|
|
|
test_var = 1 + 3
|
|
|
|
)
|
2019-09-18 14:37:08 +00:00
|
|
|
|
2019-09-25 20:17:47 +00:00
|
|
|
fn f() i32 {
|
2019-09-27 20:18:38 +00:00
|
|
|
// var a = 3;
|
2019-09-27 16:49:53 +00:00
|
|
|
// return a;
|
2019-09-25 20:17:47 +00:00
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
2019-09-27 16:39:04 +00:00
|
|
|
fn f2() i32 {
|
2019-09-27 16:49:53 +00:00
|
|
|
return f() + 2;
|
2019-09-25 21:10:17 +00:00
|
|
|
}
|
|
|
|
|
2019-09-27 16:49:53 +00:00
|
|
|
//fn f2() bool {
|
|
|
|
// return 1 > 10;
|
|
|
|
//}
|
|
|
|
|
2019-09-25 14:29:47 +00:00
|
|
|
enum B {
|
|
|
|
a
|
|
|
|
b
|
|
|
|
c
|
2019-09-25 03:26:30 +00:00
|
|
|
}
|
|
|
|
|
2019-09-27 01:22:11 +00:00
|
|
|
enum C {
|
|
|
|
blah
|
|
|
|
bluh
|
|
|
|
}
|
|
|
|
|
2019-09-25 14:29:47 +00:00
|
|
|
fn test_function() B {
|
2019-09-27 01:27:05 +00:00
|
|
|
return B.b;
|
2019-09-25 03:26:30 +00:00
|
|
|
}
|
|
|
|
|
2019-09-28 16:17:11 +00:00
|
|
|
fn func_refer_param(b: i32) i32 {
|
|
|
|
return b * 231 + b;
|
|
|
|
}
|
|
|
|
|
2019-09-24 17:12:37 +00:00
|
|
|
fn multwo(num: i32, double_flag: bool) i32 {
|
2019-09-28 20:52:30 +00:00
|
|
|
if (!double_flag) {
|
|
|
|
var value = false;
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2019-09-28 01:36:35 +00:00
|
|
|
if (double_flag) {
|
|
|
|
return num * 2;
|
2019-09-24 17:12:37 +00:00
|
|
|
} else {
|
2019-09-28 01:36:35 +00:00
|
|
|
return num;
|
2019-09-24 17:12:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-24 16:32:00 +00:00
|
|
|
fn add(a: i32, b: i32) i32 {
|
2019-09-28 00:22:03 +00:00
|
|
|
return a + b;
|
2019-09-24 16:23:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn and_fn() bool {
|
|
|
|
return true and false;
|
2019-09-18 14:37:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// type is void by default
|
2019-09-21 02:40:21 +00:00
|
|
|
//fn main() {
|
|
|
|
// print("piss\n");
|
|
|
|
// // print("2 + 2 = %d\n", add(1, 2));
|
|
|
|
//}
|