Created
September 3, 2018 20:52
-
-
Save MatthewBlanchard/24be8eccf8b2e6c0ceeab77e8a257e57 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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