groovy Closures Closure with custom target for method calls with implicit receiver


Example

class MyHello {
  def sayHello() {
    "Hello, world"
  }
}

def cl = { sayHello() }
cl() // groovy.lang.MissingMethodException    
cl.delegate = new MyHello()
cl(); // "Hello, world"

Used extensively by Groovy DSLs.