Groovy web console

subscribe to the feed Subscribe
to this
site
embed in your blog Embed
this
script
Overload your setter (via #groovywebconsole)
tweet this snippet Tweet
this
script

To embed this script in your site, just drop the content below where you want to embed it.

Overload your setter

Published 1 month ago by Sebastien Blanc with tags metaClass dynamic overloading
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
class Foo {
String name
}

class Bar {
Foo foo
}
Bar.metaClass.setFoo= {String value->
 Foo foo = new Foo()
 foo.name = value
 delegate.setFoo(foo)

}
Bar bar = new Bar()
bar.foo = "test"
bar.foo.name


Recent scripts