my_basic
my_basic copied to clipboard
Class member variable default value issue
As demonstrated in the below sample:
class foo
var a = 1
def inc()
a = a + 1
enddef
Endclass
class bar(foo)
var class = "test"
Endclass
boo = new(foo)
boo.inc() ; incrementing boo.a also increments zap.a?
zap = new(bar)
; zap.a = 1
; have to initialize zap.a to not increment issue above,
; but what is the point of having class variable default values?
; boo.inc() ; putting the call here also seems to not increment zap.a
zobj = reflect(zap)
loop = iterator(zobj)
While move_next(loop)
name = get(loop)
value = zobj(name)
Print name, " = ", value
Wend
outputs
CLASS = test
A = 2 ; should be 1 since boo.inc() is called, not zap.inc()
...
...