diff --git a/13_functions/init.v b/13_functions/init.v new file mode 100644 index 0000000..555a869 --- /dev/null +++ b/13_functions/init.v @@ -0,0 +1,9 @@ + +// init() can not be pub +fn init(){ + println('oi') +} + +pub fn main(){ + init() +} \ No newline at end of file diff --git a/14_constants/constants.v b/14_constants/constants.v new file mode 100644 index 0000000..9c7d7e7 --- /dev/null +++ b/14_constants/constants.v @@ -0,0 +1,39 @@ + +const pi = 3.14 +const e = 2.71828 +const world = '世界' + +struct Color{ + r int + g int + b int +} + +fn rgb(r int, g int, b int) Color +{ + return Color{ + r: r + g: g + b: b + } +} + +const numbers = [1,2,3] +const red = Color{ + r: 255 + g: 0 + b: 0 +} + +const blue = rgb(0,0, 255) + +pub fn main(){ + + println(pi) + println(world) + + println(numbers) + println(red) + println(blue) + +} \ No newline at end of file diff --git a/14_constants/module.v b/14_constants/module.v new file mode 100644 index 0000000..24b3e2b --- /dev/null +++ b/14_constants/module.v @@ -0,0 +1,7 @@ +module mymodule + +pub const golden_ratio = 1.61803 + +fn calc(){ + println(mymodule.golden_ratio) +}