| 1 | module main |
| 2 | |
| 3 | struct Custom { |
| 4 | name string |
| 5 | } |
| 6 | |
| 7 | interface MyInterface { |
| 8 | some_function() |
| 9 | } |
| 10 | |
| 11 | fn (c Custom) some_function() { |
| 12 | println('hello ${c.name} from ${@METHOD}') |
| 13 | } |
| 14 | |
| 15 | fn main() { |
| 16 | a := Custom{'rabbit'} |
| 17 | x := a.some_function |
| 18 | x() |
| 19 | b := Custom{'horse'} |
| 20 | y := b.some_function |
| 21 | y() |
| 22 | |
| 23 | c := Custom{'noname'} |
| 24 | |
| 25 | $for method in MyInterface.methods { |
| 26 | z := fn [c] () { |
| 27 | c.$method() |
| 28 | } |
| 29 | z() |
| 30 | } |
| 31 | } |
| 32 |