In examples of groovy code I find the -> operator everywhere, but the groovy tutorials nor the book I have seem to provide any explaination as to what this means.
In examples of groovy code I find the -> operator everywhere, but the groovy
Share
It is used to separate where you declare bindings for your closure from the actual code, eg:
the part before
->declares that the closure has two arguments namedxandywhile the second part is the code of the closure.You can omit it in closures with just one parameter, in that case the
itvariable is assumed:but you could also do