From:
http://www.giderosmobile.com/forum/discussion/806/inheritance-troublesI believe this is a bug and didn't want it to get lost so I figured I'd repost it:
A = Core.class()
function A:init()
print(self)
end
B = Core.class(A)
function B:init()
print(self)
end
local b = B.new() |
The value of self in the two init functions are different when "b" is created. This is not what most people would expect and can cause subtle & difficult to find problems.
--ND
Comments
Another example...
Let me change deep copy to shallow copy and test extensively.
@ndoss, your latest example works well. Although they are different selfs, they refer to the same Sprite instance internally on C++ side.
(And honestly I don't remember why I preferred deep copy instead of shallow )
Thank you