ByRef does not work for arrays which are class member
Posted: 06 Feb 2021, 05:15
I'm using AutoHotkey_2.0-a123-e5801ee8, the latest version as of now.
Suppose there is a function:
Passing a normal array to it gives the expected result:
But if an array belonging to some class is provided, there's error:
by the way, foo(&a){...} does not work as indicated in https://www.autohotkey.com/boards/viewtopic.php?f=37&t=86283
Suppose there is a function:
Code: Select all
foo(ByRef a) {
a := []
a.Push("1")
a.Push("2")
}
Code: Select all
b := []
foo(b)
MsgBox b[1] ; MsgBox'es 1
Code: Select all
class bar {
b := []
__New() {
foo(this.b)
MsgBox this.b[1] ; throws "Invalid index" exception
}
}
d := bar.New()
MsgBox d.b[1] ; again the same exception