Code: Select all
test := Map()
test.Default := []
test["a"].Push(1)
test["b"] := []
test["b"].Push(2)
MsgBox("a: " test["a"][1] "`nb: " test["b"][1])
for k, v in test
MsgBox("key: " k "`nvalue: " v[1])
Code: Select all
test := Map()
test.Default := []
test["a"].Push(1)
test["b"] := []
test["b"].Push(2)
MsgBox("a: " test["a"][1] "`nb: " test["b"][1])
for k, v in test
MsgBox("key: " k "`nvalue: " v[1])
Code: Select all
test := Map()
test.Default := []
test["a"].Push(1)
test["b"].Push(2)
msgbox test["a"][1] test["a"][2] ; outputs 12 (notice the same key)
Code: Select all
class MapWithArrayDefault extends Map {
default[*] => []
add(val) => this[val] := this[val]
}
mymap := MapWithArrayDefault()
mymap.add("a").push(1)
mymap.add("b").push(2)
msgbox mymap["a"][1] ; 1
msgbox mymap["b"][1] ; 2
Code: Select all
test := Map()
other := test
test["a"] := 1
MsgBox(other["a"])