Page 1 of 1

[a104] static __new triggered twice

Posted: 21 Aug 2019, 18:24
by aseiot
Document wrote:Each class may also have a static __New method, which is called immediately after its static variables are initialized (this occurs in the order that classes are defined in the script). This method can be inherited from a base class, and can therefore be used to initialize subclasses. Within static __New, this refers to either the class which defined the method, or a subclass.
But I found it will be called twice upon initiation. Is that by design?

Code: Select all

class x
{
	static __New(){
		MsgBox "in __New"
	}
}

Re: [a104] static __new triggered twice  Topic is solved

Posted: 22 Aug 2019, 18:05
by aseiot
Sorry, I found this happened when class is extends. In following code, __New will be called third times. So it is not a problem. :oops:

Code: Select all

class x
{
	static __New(){
		MsgBox "in __New"
	}
}
class y extends x
{
}
class z extends x
{
}