| 1 | struct TestStruct {} |
| 2 | |
| 3 | fn (t TestStruct) one_arg(a string) string { |
| 4 | println(a) |
| 5 | return a |
| 6 | } |
| 7 | |
| 8 | fn (t TestStruct) two_args(a string, b int) string { |
| 9 | println('${a}:${b}') |
| 10 | return a |
| 11 | } |
| 12 | |
| 13 | fn test_main() { |
| 14 | t := TestStruct{} |
| 15 | mut out := '' |
| 16 | $for method in TestStruct.methods { |
| 17 | $if method.name == 'one_arg' { |
| 18 | res := t.$method(method.name) |
| 19 | out += res |
| 20 | } $else $if method.name == 'two_args' { |
| 21 | res := t.$method(method.name, 42) |
| 22 | out += res |
| 23 | } |
| 24 | } |
| 25 | assert out == 'one_argtwo_args' |
| 26 | } |
| 27 | |