From 716dbbcdfb4adc06dd5b47843697d7525c029a0f Mon Sep 17 00:00:00 2001 From: Vinicius Silva Date: Sat, 23 Dec 2023 09:58:30 -0300 Subject: [PATCH] Moving codes to 05_conditions --- 05_conditions/if.v | 51 +++++++++++++++++++++++++++++++++++++++++++ 05_conditions/match.v | 4 ++++ 2 files changed, 55 insertions(+) create mode 100644 05_conditions/if.v create mode 100644 05_conditions/match.v diff --git a/05_conditions/if.v b/05_conditions/if.v new file mode 100644 index 0000000..84fcc28 --- /dev/null +++ b/05_conditions/if.v @@ -0,0 +1,51 @@ + + +pub fn main() +{ + mut a := 10 + mut b := 20 + + // Simple if structure + if a < b + { + println("${a} é menor do que ${b}") + }else if a > b + { + println("${a} é maior do que ${b}") + }else + { + println("${a} é igual a ${b}") + } + + num := 777 + + s := if num % 2 == 0 { 'even' } else { 'odd' } + println(s) + + + // ================================================================ // + + m := { + 'foo' : 'bar' + } + + if v := m['foo'] + { + println(v) + }else + { + println('not found') + } + + if c := res() + { + println(c) + } + + // ================================================================ // +} + +fn res() !int +{ + return 42 +} \ No newline at end of file diff --git a/05_conditions/match.v b/05_conditions/match.v new file mode 100644 index 0000000..39a5f15 --- /dev/null +++ b/05_conditions/match.v @@ -0,0 +1,4 @@ +pub fn main() +{ + println('oi') +} \ No newline at end of file