-
-
Save darmie/7f98da2d09ac8e28fc839078ef58be30 to your computer and use it in GitHub Desktop.
Implementation of instanceof in Lua
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
function instanceOf (subject, super) | |
super = tostring(super) | |
local mt = getmetatable(subject) | |
while true do | |
if mt == nil then return false end | |
if tostring(mt) == super then return true end | |
mt = getmetatable(mt) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment