Groovy web console

subscribe to the feed Subscribe
to this
site
respondsTo (via #groovywebconsole)
tweet this snippet Tweet
this
script

respondsTo

Published 7 months ago by Gabriel Bianchi with tags respondsTo
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
interface I {
    void a()
}

class A implements I {
    void a() {
        println 'a'
    }
}

class B extends A {
    void b() {
        println 'b'
    }
}

I obj = new A()
obj.a()
obj.respondsTo('b') && obj.b()
I obj2 = new B()
obj2.a()
obj2.respondsTo('b') && obj2.b()