How to check if a method exists in Lua?
function Object:myMethod() end
function somewhereElse()
local instance = Object()
if instance:myMethod then
-- This does not work. Syntax error: Expected arguments near then.
-- Same with type(...) or ~=nil etc. How to check colon functions?
end
end
It's object-oriented programming in Lua. Check for functions or dot members (table) is no problem. But how to check methods (:)?
