Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Class member variable default value issue #81

Open
blazer2k1 opened this issue Sep 20, 2023 · 0 comments
Open

Class member variable default value issue #81

blazer2k1 opened this issue Sep 20, 2023 · 0 comments
Labels

Comments

@blazer2k1
Copy link

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()
...
...
@blazer2k1 blazer2k1 changed the title Class member variable default value questions Class member variable default value issue Sep 21, 2023
@paladin-t paladin-t added the bug label Sep 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants