title: Lua check if method exists
body: <p>How to check if a method exists in Lua?</p>
  <pre class="lang-lua prettyprint-override"><code>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
  </code></pre>
  <p><a href="https://i.stack.imgur.com/Zva9p.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Zva9p.png" alt="enter image description here" /></a></p>
  <p>It's <a href="https://www.lua.org/pil/16.html" rel="nofollow noreferrer">object-oriented programming in Lua</a>. Check for functions or dot members (table) is no problem. But how to check methods (<code>:</code>)?</p>