Log In  
Follow
FuzzyDunlop
Follow

I'm just starting out in PICO-8 and messing around with OOP-style prototypal inheritance, so I tried to run the following code:

myclass = {str = "printme"}

function myclass:new(o)
 o = o or {}
 setmetatable(o,self)
 self._index = self
 return o
end

subclass = myclass:new()
print(subclass.str)

...and it prints [nil] .

Should it not print "printme"? What am I doing wrong here?

P#71795 2020-01-06 21:21 ( Edited 2020-01-06 21:21)

Follow Lexaloffle:        
Generated 2020-02-22 18:06 | 0.070s | 4194k | Q:10