| 1 | import os |
| 2 | |
| 3 | struct StructWithMap { |
| 4 | mut: |
| 5 | name string |
| 6 | m map[string]StructWithMap |
| 7 | } |
| 8 | |
| 9 | fn abc() (&StructWithMap, &map[string]StructWithMap) { |
| 10 | mut s := &StructWithMap{} |
| 11 | s.m['abc'] = StructWithMap{'abc', {}} |
| 12 | pointer_to_map_value := &s.m['abc'].m['xyz'].m |
| 13 | dump(ptr_str(pointer_to_map_value)) |
| 14 | return s, pointer_to_map_value |
| 15 | } |
| 16 | |
| 17 | fn main() { |
| 18 | mut s, p := abc() |
| 19 | n := os.args[1] or { '2' }.int() |
| 20 | dump(n) |
| 21 | for i in 0 .. n { |
| 22 | s.m['${i}'] = StructWithMap{} |
| 23 | } |
| 24 | dump(s.m['abc']) |
| 25 | dump(p) |
| 26 | eprintln('-----------------------------------------------------') |
| 27 | } |
| 28 | |