| 1 | struct Foo { |
| 2 | bar ?fn () |
| 3 | } |
| 4 | |
| 5 | fn test_main() { |
| 6 | foo1 := Foo{ |
| 7 | bar: || println('foo1') |
| 8 | } |
| 9 | foo2 := Foo{ |
| 10 | bar: fn () { |
| 11 | println('foo2') |
| 12 | } |
| 13 | } |
| 14 | if bar_fn := foo1.bar { |
| 15 | bar_fn() |
| 16 | assert true |
| 17 | } else { |
| 18 | assert false |
| 19 | } |
| 20 | if bar_fn := foo2.bar { |
| 21 | bar_fn() |
| 22 | assert true |
| 23 | } else { |
| 24 | assert false |
| 25 | } |
| 26 | } |
| 27 |