Hi,
My understanding of the Groovy operator .&
is that it converts a method call to a closure. Therefore it seems like the following code (which can be run in the Groovy console) should work:
class Foo {
def method(def param) {
param + 10
}
}
def invokeClosure = {Closure closure ->
return closure.call()
}
def f = new Foo()
invokeClosure f.&method(6)
Of course if I change the last line to
invokeClosure {f.method(6)}
it works fine, but what's wrong with my understanding of the .&
operator?
Thanks, Don