Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local object = {}
- function object:new(o)
- o = o or {}
- setmetatable(o, self)
- self.__index = self
- return o
- end
- function object:clone()
- local o = self:new(self)
- return o
- end
- function object:equals(o)
- return self == o
- end
- function object.__eq(a, b)
- if a.equals then
- return a:equals(b)
- elseif b.equals then
- return b.equals(a, b)
- end
- error("No such equality operator (==) exists for " .. a .. " or " .. b ..".")
- return false
- end
- return object
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement