| 1 | @[heap] |
| 2 | struct HeapImage { |
| 3 | mut: |
| 4 | id int |
| 5 | } |
| 6 | |
| 7 | fn create_image() ?HeapImage { |
| 8 | return HeapImage{ |
| 9 | id: 42 |
| 10 | } |
| 11 | } |
| 12 | |
| 13 | fn main() { |
| 14 | if img := create_image() { |
| 15 | println(img.id) |
| 16 | } |
| 17 | image := HeapImage{ |
| 18 | id: 7 |
| 19 | } |
| 20 | mut images := []HeapImage{} |
| 21 | images << image |
| 22 | indexed := images[0] |
| 23 | println(indexed.id) |
| 24 | } |
| 25 |