Thanks for breaking it down, Helgef.
Helgef wrote:where this.base refers to the class BaseKeyword2
This is hard to understand...; `this.base` does not refer to the base object but the derived object for the first time.
This seems to be the AutoHotkey way, however. I don't think I fully understand this behavior and I decided to stay away from `this.base`.
I leave the below note for anybody who gets similar confusion.
Code: Select all
global iCallCount := 0
o := new BaseKeyword2
msgbox % "Result`n"
. "p: " o.iCallCount "`n" ; shows 1
. "g: " iCallCount ; shows 2
class BaseKeyword {
__New() {
}
}
class BaseKeyword2 extends BaseKeyword {
iCallCount := 0
__New() {
this.base.__New()
; base.__New() ; does not cause the issue
iCallCount++ ; gloval variable
this.iCallCount++ ; class property
this.check( iCallCount, this.iCallCount )
}
check( iGlobalCount, iPropertyCount ) {
msgbox % A_ThisFunc "`n"
. "p: " iPropertyCount "`n"
. "g: " iGlobalCount
}
}