title: Why does metaClass.hasProperty allow one parameter when it actually needs two parameters
body: <p>Dealt with a rather confusing bug this week.</p>
  <p>Our codebase had the following, assuming <code>example['test']</code> is valid and the property <code>example</code> is also valid:</p>
  <p><code>example['test'].metaClass.hasProperty(&quot;example&quot;)</code></p>
  <p>This was valid code, compiled, and even ran in Jenkins and through all our unit tests fine. It wasn't until we noticed that this actually wasn't producing the results we wanted did we realize it was wrong. According to the <a href="https://docs.groovy-lang.org/latest/html/api/groovy/lang/MetaObjectProtocol.html#hasProperty(java.lang.Object,java.lang.String)" rel="nofollow noreferrer">documentation</a> it needs an object <strong>and</strong> a string.</p>
  <p>Eventually we fixed the bug by creating the object and passing in the object and string</p>
  <pre><code>example_params = example['test']
  example['test'].metaClass.hasProperty(example_params, &quot;example&quot;)
  </code></pre>
  <p>Why is <code>metaClass.hasProperty</code> allowed to compile with just one parameter when it actually needs two?</p>