> Try: > test = Person() > print(tostring(test)) > "instance of class Person" > print(test) > .../middleclass.lua:66: class Person doesn't implement metamethod '__len' Hm, both of these work for me. I'm running the latest middleclass from github: local Person = class('Person') function Person:initialize(name) self.name = name end function Person:speak() print('Hi, I am ' .. self.name ..'.') end print(Person) local person = Person() print(person) print(tostring(person)) -- output class Person instance of class Person instance of class Person Or am I doing something differently? Paul. On Wed, Mar 12, 2014 at 3:57 PM, Rob Probin <rob.probin@xxxxxxxxx> wrote: > > > On 12/03/2014 22:51, Rob Probin wrote: >> >> >>> What do you do to get this error? I tried the following (including the >>> earlier fix for __serialize): >>> >>> local Person = class('Person') >>> print(#Person) >>> >>> And it prints 0 without any errors. >>> >> In the remote console, whilst running my code (at a breakpoint) >> print(#Person) and print(pairs(Person)) work for me as well. But why >> wouldn't it call the metamethods? (maybe I'm missing something obvious...) >> > > Because it's using the Class metatable not the object metatable.... > e.g. print(Person) > > shows: "class Person" > > Rather than > > "instance of Person" > > Try: > test = Person() > print(tostring(test)) > "instance of class Person" > print(test) > .../middleclass.lua:66: class Person doesn't implement metamethod > '__len' > > > >