You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@groovy.apache.org by Anto Aravinth <an...@gmail.com> on 2015/09/16 08:55:11 UTC

Expando Metaclass doesnt throw error on duplicate method

Hi all,

I have this code:

class A {
}

A.metaClass.hello = {
  "hello superclass"
}

class B extends A {
}

B.metaClass.hello << {
  "hello subclass"
}

B.metaClass.hello << {
  "hello subclass"
}

new B().hello()

As you can see I could able to define hello method twice. But doc says it
will throw an exception if it sees a method if already present.

Groovy version : 2.2