Autohotkey 如何调整作为参数传递的数组的索引?
我已经重写了_arraybase对象以允许0个基本数组,但是我注意到了一个bug,我希望能得到一些帮助 有关调整:Autohotkey 如何调整作为参数传递的数组的索引?,autohotkey,Autohotkey,我已经重写了_arraybase对象以允许0个基本数组,但是我注意到了一个bug,我希望能得到一些帮助 有关调整: Array(_parameters*) { r := {} Loop, % Round(_parameters.Length()) r[A_Index - 1] := _parameters[A_Index] r.base := _Array Return (r) } Class _Array { Length[] {
Array(_parameters*) {
r := {}
Loop, % Round(_parameters.Length())
r[A_Index - 1] := _parameters[A_Index]
r.base := _Array
Return (r)
}
Class _Array {
Length[] {
Get {
Return (Round(this.MaxIndex() + 1))
}
}
IsArray[] {
Get {
Return (1)
}
}
Push(_elements*) {
s := this.Length, m := Round(_elements.MaxIndex())
If (m)
this.InsertAt(s, _elements*)
Return (s + m)
}
Concat(_elements*) {
r := this.Clone()
MsgBox, % "222: " . _elements.Length() ;_elements.Length is not acceptable because this special parameter array (A_Args) does not get modified.
MsgBox, % "333: " . (_elements.base.__Class ? "y" : "n") ;No base.
For i, v in _elements {
If (v.IsArray) {
Loop, % v.Length
r.Push(v[A_Index - 1])
}
Else
r.Push(v) ;Catch for objects and string/integer values.
}
Return (r)
}
Join(_separator := ",") {
s := Round(this.MaxIndex())
For i, v in this
r .= (v.IsArray ? "[Array]" : IsObject(v) ? "{Object}" : v) . (i < s ? _separator : "")
Return (r)
}
}
我已经确认,将数组*作为参数传递会创建一个a_Args数组,但它没有可操作的基础。我能做些什么来纠正这种行为吗
F1::
arrays := [[1,2,3]
, [4,5,6]
, [7,8,9]]
MsgBox, % "111: " . arrays.Length
MsgBox, % [].concat(arrays*).Join(", ") ;[4, 5, 6, 7, 8, 9]. Missing [1, 2, 3]
Return