[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Once a newbie, always a newbie
- From: Dirk Laurie <dirk.laurie@...>
- Date: Fri, 31 Aug 2012 09:25:31 +0200
I have been programming Lua for nearly two years, and it still
took me several minutes to find the bug.
----
MyClass = {}
function MyClass.init(class,myclass)
setmetatable(myclass,class)
return myclass
end
function MyClass.__gt(x,y) return x:cmp(y)>0 end
function MyClass.cmp(x,y) -- details unimportant, it is defined
end
setmetatable(MyClass,{__call=MyClass.init})
MyClass.__index=MyClass
----
> print (MyClass{1,2}>MyClass{1,3})
stdin:1: attempt to compare two table values
stack traceback:
stdin:1: in main chunk
[C]: in ?