That codes converts map to multidimensional map. The old code is too complicated. There's an easier way to convert it using Map.Prototype := MultiDimMap.Prototype.
See the bottom for an example:
And if I need to use map to declare an associative array what I must make?
See the bottom for an example:
CODE:
#Requires AutoHotkey v2.0
class MultiDimMap extends Map {
static __New() {
Map.Prototype := MultiDimMap.Prototype
}
__Item[k1, p*] {
Get => p.Length ? super[k1][p*] : super[k1]
Set {
if p.Length && (!super.Has(k1) || !(super[k1] is Map))
super[k1] := (m := Map(), m.CaseSense := this.CaseSense, m)
(p.Length)
? super[k1][p*] := value
: super[k1] := value
}
}
}
; associative array
myMap := Map()
myMap["a"] := 97
myMap["b"] := 98
myMap["c"] := 99
MsgBox myMap["a"]
; multidimensional map
nDimMap := Map()
nDimMap["a", "b", "c"] := "ABC"
nDimMap["x", "y", "z"] := "XYZ"
MsgBox nDimMap["a", "b", "c"]
Statistics: Posted by ntepa — Today, 16:25