Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Object in super class' init function is not the same as in the inherited class' init function ? — Gideros Forum

Object in super class' init function is not the same as in the inherited class' init function ?

bysregbysreg Member
edited September 2012 in General questions
suppose i have
--A.lua
A = Core.class()
function A:init()
print("A",self)
end

--B.lua
B = Core.class()
function B:init()
print("B",self)
end

when i try to create object of class B it actually prints :

A table: X
B table: Y

with X ~= Y. Is this the expected behavior? i was expecting X = Y, because the object should be the same.
because of this, code below :

--A.lua
A = Core.class()
function A:init()
self:foo()
end

function A:foo()
print("x")
end

--B.lua
B = Core.class(A)
function B:init()
end
function B:foo()
print("y")
end

will output "x". it should've been "y" right? am i missing something here?

Comments

Sign In or Register to comment.