Closures
A closure is a function that you can pass as an argument to another function.
It is contained by curly brackets, {<closure>}
.
You can also define variables before the arrow ->
Tip For more extensive documentation about closures, please refer to the Groovy closure documentation.
Examples
Closure | Purpose |
---|---|
{a, b -> a + b} |
|
{String a -> isNotEmpty (a) } |
|
{isNotEmpty (it)} |
Tip Naming an argument is not necessary when there is only one. |