1module main 2 3// import moda 4 5// import ( 6// modb 7// modc 8// ) 9 10fn main() { 11 b := Bar{a: 122} 12 mut a := Foo{ 13 a: 'hello' 14 b: b 15 } 16 a.a = 'da' 17 a.b.a = 111 18 19 a1 := a.a 20 a2 := b.testa() 21 22 mut c := testa() 23 c = 1 24 mut d := testb(1) 25 d = 'hello' 26 27 mut e := 'hello' 28 e = testb(111) 29 e = 'world' 30 31 mut f := [testa(),2,3,4] 32 mut g := [testb(1),'hello'] 33 34 //mut arr_foo := []Foo 35 arr_foo := [a] 36 //arr_foo << a // TODO 37 af_idx_el := arr_foo[0] 38 foo_a := af_idx_el.a 39 40 mut m1 := map[string]string 41 mut m2 := {'v': 1, 'lang': 2} 42 43 ma1, ma2 := 'hello', 'vlang' 44 mr1, mr2 := mr_test() 45 46 opt1, opt2, opt3, opt4 := 'opt1', optional_a(), 'opt3', optional_b() 47 opt_mr1, opt_mr12 := optional_mr() or { 48 // err 49 } 50} 51 52fn mr_test() (int, string) { 53 return 1,'v' 54} 55 56fn testa() int { 57 return testc(1) 58} 59 60fn testb(a int) string { 61 return 'hello' 62} 63 64fn testc(a int) int { 65 return a 66} 67 68fn (f &Foo) testa() int { 69 mut a := f.testb() 70 a = 1 71 return 4 72} 73 74fn (f &Foo) testb() int { 75 return 4 76} 77 78fn (b &Bar) testa() int { 79 return 4 80} 81 82struct Bar { 83 a int 84} 85 86struct Foo{ 87 a string 88 b Bar 89} 90 91fn optional_a() ?string { 92 return '111' 93} 94 95fn optional_b() ?string { 96 return '222' 97} 98 99fn optional_mr() ?(int, string) { 100 return 1, '111' 101} 102 103