5 # Tables store key-value pairs.
6 # You can define a table using `{key: value, ...}`.
8 scores := {"Alice": 100, "Bob": 200}
9 assert scores == {"Alice": 100, "Bob": 200}
11 assert scores["Alice"] == ???
13 # Accessing a missing key gives `none`
14 assert scores["Zoltan"] == ???
16 # Tables can be empty but must have key and value types:
17 empty : {Text:Int} = {}
20 # You can loop over tables:
22 for name, score in scores
27 # Table keys and values can be accessed as an array:
28 assert scores.keys == [???]
30 assert scores.values == [???]
32 # Table comprehensions let you create tables concisely:
33 doubled := {k: v * 2 for k, v in scores}
34 assert doubled == {???}