| 1 |
func test(): |
| 2 |
# Non-string keys are valid. |
| 3 |
print({ 12: "world" }[12]) |
| 4 |
|
| 5 |
var contents = { |
| 6 |
0: "zero", |
| 7 |
0.0: "zero point zero", |
| 8 |
null: "null", |
| 9 |
false: "false", |
| 10 |
[]: "empty array", |
| 11 |
Vector2i(): "zero Vector2i", |
| 12 |
15: { |
| 13 |
22: { |
| 14 |
4: ["nesting", "arrays"], |
| 15 |
}, |
| 16 |
}, |
| 17 |
} |
| 18 |
|
| 19 |
print(contents[0.0]) |
| 20 |
# Making sure declaration order doesn't affect things... |
| 21 |
print({ 0.0: "zero point zero", 0: "zero", null: "null", false: "false", []: "empty array" }[0]) |
| 22 |
print({ 0.0: "zero point zero", 0: "zero", null: "null", false: "false", []: "empty array" }[0.0]) |
| 23 |
|
| 24 |
print(contents[null]) |
| 25 |
print(contents[false]) |
| 26 |
print(contents[[]]) |
| 27 |
print(contents[Vector2i()]) |
| 28 |
print(contents[15]) |
| 29 |
print(contents[15][22]) |
| 30 |
print(contents[15][22][4]) |
| 31 |
print(contents[15][22][4][0]) |
| 32 |
print(contents[15][22][4][1]) |
| 33 |
|
| 34 |
# Currently fails with "invalid get index 'hello' on base Dictionary". |
| 35 |
# Both syntaxes are valid however. |
| 36 |
#print({ "hello": "world" }["hello"]) |
| 37 |
#print({ "hello": "world" }.hello) |