Groovy web console

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

something

Published 3 months ago by shane
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts


class Person {
    def name
    def dog
}

class Dog {
    def name
}

def d = new Dog(name: "rex")
def p = new Person(name: "shane", dog: d)
def command = "getDog getName"
def obj = p
command.split(' ').each { c->
   println c
   obj = obj."$c"()
    

}
println obj