like this:
Groovy:
map = ['a':1,'b':2]
doubler = this.&doubleMethod
map.each(doubler)
println map
What's the "&" used for here?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With