| 1 | module main |
| 2 | |
| 3 | struct Int { |
| 4 | mut: |
| 5 | value int |
| 6 | test map[string]int |
| 7 | hello []int |
| 8 | } |
| 9 | |
| 10 | fn (mut i Int) add(value int) { |
| 11 | i.value += value |
| 12 | } |
| 13 | |
| 14 | fn (i Int) get() int { |
| 15 | return i.value |
| 16 | } |
| 17 | |
| 18 | struct Config { |
| 19 | foo int |
| 20 | bar string |
| 21 | } |
| 22 | |
| 23 | fn use_config(c Config) { |
| 24 | } |
| 25 | |
| 26 | fn main() { |
| 27 | mut a := Int{ |
| 28 | value: 10 |
| 29 | } |
| 30 | a.add(5) |
| 31 | println(a) // 15 |
| 32 | mut b := Int{} |
| 33 | b.add(10) |
| 34 | println(b.get()) // 10 |
| 35 | use_config(Config{2, 'bar'}) |
| 36 | use_config( |
| 37 | foo: 2 |
| 38 | bar: 'bar' |
| 39 | ) |
| 40 | } |
| 41 |