From e50b4e9299b6cd2dce223acccc6f6367dbd382a9 Mon Sep 17 00:00:00 2001 From: Vinicius Silva Date: Sun, 31 Dec 2023 00:22:03 -0300 Subject: [PATCH] init.v created on 13_functions directory --- 13_functions/init.v | 9 +++++++++ 14_constants/constants.v | 39 +++++++++++++++++++++++++++++++++++++++ 14_constants/module.v | 7 +++++++ 3 files changed, 55 insertions(+) create mode 100644 13_functions/init.v create mode 100644 14_constants/constants.v create mode 100644 14_constants/module.v 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) +}