fincs wrote: ↑08 Jan 2020, 07:05
In neither case is the target of the operation an already-initialized variable/field:
this.stat:=!this.stat: This is a GET operation on a not-yet-existing field followed by a SET. Since it's reading from a field that doesn't exist it throws an exception.
stat:=!stat: This reads an uninitialized global variable, and therefore it triggers a warning when
#Warn (UseUnsetGlobal) is used.
A common recommendation even in scripting languages is to initialize variables you're going to use later with an actual predictable value.
I understand why this happens
;Object.__Item.Get() return exception but must return "", but don`t understand who is needed ???
Let see next:
Code: Select all
class Item {
__New() {
this.stat:= "" ;create member
this.stat:=!this.stat ;this.stat become TRUE
} }
o:= Item.new() ;here we corectly create and init this.stat
o.DeleteProp("stat")
MsgBox(o.stat) ;exception the same but more complicated
So if user need to f.cked up script he can.
And the same in AHKv2.0-a100
Code: Select all
;AHKv2.0-a100
class Item {
__New() {
this.stat:=!this.stat ;this.stat become TRUE
} }
o:= new Item()
MsgBox(o.stat)
So JUST if
Object.__Item.Get() return "" all of this equilibristics become unnecessary.
I override Array and Map
How I think Array and Map must work in AHKv2.0 (current version a108) , now I will override Object too, BUT it is unnecessary at all for AHK.