Groovy web console

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

@Delegate example

Published 1 month ago by Anonymous
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
class A {

  def greetings = { String world -> println "Hello ${world}" }
}

class B {
  @Delegate
  private final A a = new A()

  def sayHi(String world) {
    greetings(world)
  }
}

new B().sayHi('England')