#Requires AutoHotkey v2.0 ; m := Map("dad", 23, "frg", 455, "zz", 232) m := { dad : 23, frg : 455, zz : "value2" } vals := values(m) MsgBox vals[3] values(m) => [m.__Enum(2).Bind(&_)*] ; https://www.autohotkey.com/boards/viewtopic.php?f=82&t=119529 /* ; for遍历的写法 myMap := Map("key1", "value1", "key2", "value2") keys := [], values := [] for k, v in myMap keys.Push(k), values.Push(v) */ /* ; based on https://github.com/HelgeffegleH/AHK-misc./tree/master/classes/map_n class MapN extends Map { __Item[k1, p*] { get => p.Length ? super[k1][p*] : super[k1] set { if p.Length && (!super.Has(k1) || !(super[k1] is MapN)) super[k1] := (m:=MapN(), m.CaseSense := this.CaseSense, m) (p.Length) ? super[k1][p*] := value : super[k1] := value } } __Enum(NumOfVars) { local inner, key, outer := super.__Enum(Min(2, NumOfVars)) if NumOfVars <= 2 return outer next(p*) { vkey := p.RemoveAt(1) while !IsSet(inner) || !inner(p*) { if !outer(&key, &m) return false inner := m.__Enum(p.Length) } %vkey% := key return true } return next } } ; https://www.autohotkey.com/boards/viewtopic.php?f=82&t=119160 mn := MapN() mn["a", "b", "c", "d", "e", "f"] := "abcdef" mn[1, 2, 3, 4, 5, 6] := 123456 mn["t", "u", "v", "w", "x", "y"] := "tuvwxy" out := "" for a, b, c, d, e, f, g in mn { out .= "mn[" a ", " b ", " c ", " d ", " e ", " f "] = " g "`n" } MsgBox out */
声明:站内资源为整理优化好的代码上传分享与学习研究,如果是开源代码基本都会标明出处,方便大家扩展学习路径。请不要恶意搬运,破坏站长辛苦整理维护的劳动成果。本站为爱好者分享站点,所有内容不作为商业行为。如若本站上传内容侵犯了原著者的合法权益,请联系我们进行删除下架。
评论(0)