tags:

views:

75

answers:

1

like this:
Groovy:

map = ['a':1,'b':2]
doubler = this.&doubleMethod
map.each(doubler)
println map

What's the "&" semanteme used here?

+4  A: 

the .& operator is a method reference, i.e. it turns the indicated method into a closure so that it can be passed to other methods that want a closure as an argument.

Kieron