| 1 | module main |
| 2 | |
| 3 | enum State { |
| 4 | idle |
| 5 | run |
| 6 | } |
| 7 | |
| 8 | fn make_explicit() map[State]int { |
| 9 | return { |
| 10 | .idle: 10 |
| 11 | .run: 20 |
| 12 | } |
| 13 | } |
| 14 | |
| 15 | fn make_from_context() map[State]int { |
| 16 | return { |
| 17 | .idle: 30 |
| 18 | .run: 40 |
| 19 | } |
| 20 | } |
| 21 | |
| 22 | fn main() { |
| 23 | a := make_explicit() |
| 24 | b := make_from_context() |
| 25 | println(a[State.idle]) |
| 26 | println(a[State.run]) |
| 27 | println(b[State.idle]) |
| 28 | println(b[State.run]) |
| 29 | } |
| 30 |