A_AhkUser wrote:
You can also use alternatively:
Ahk has some confusing rules for references and objects, Wasn't aware you could act directly on the function like that, too used to C# and Lua style objects.
I like
ObjBindMethod(this, "functionname") better though, its meaning is more explicit.
A_AhkUser wrote:Code: Select all
i.free() ; so that the line below triggers the __Delete meta-function
i := ""
Ah, Yea this is something that should be expanded on in the docs, I assumed you could nop an objects properties in
__Delete itself and not have to worry about it.
so if I have __Delete like this:
Code: Select all
...
__Delete() {
prop1 := ""
return ""
}
...
myObj := myObj.__Delete()
It would technically call __Delete twice?
Code: Select all
global c := 0
i := new Test()
i := i.__Delete()
return
Class Test {
__Delete() {
c++
MsgBox, % c
return ""
}
}
it does twice.
but this doesn't at all:
Code: Select all
global c := 0
i := new Test()
i := ""
return
Class Test {
__New() {
this.delete_ref := ObjBindMethod(this, "__Delete")
}
__Delete() {
this.delete_ref := ""
c++
MsgBox, % c
return ""
}
}
I could do this to dispose of objects, seems to work:
Code: Select all
DeleteObject(ByRef object) {
for i, v in object {
object[i] := ""
}
object := ""
}