Skip to content

Instantly share code, notes, and snippets.

@MatthewBlanchard
Created September 3, 2018 20:52
Show Gist options
  • Save MatthewBlanchard/24be8eccf8b2e6c0ceeab77e8a257e57 to your computer and use it in GitHub Desktop.
Save MatthewBlanchard/24be8eccf8b2e6c0ceeab77e8a257e57 to your computer and use it in GitHub Desktop.
Object = {}
-- Metamethods
function Object:__call(...)
return self:new(...)
end
-- Constructor
function Object:__new()
end
-- Methods
function Object:new(...)
local o = {}
setmetatable(o, self)
self.__index = self
self.__call = Object.__call
o:__new(...)
return o
end
function Object:is(o)
local parent = getmetatable(self)
while parent do
if parent == o then
return true
end
parent = getmetatable(parent)
end
return false
end
return Object:new()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment