Closures and Switch Statements
Learn about closures and switch statements in Groovy.
We'll cover the following...
Closures
A closure is a block of code in Groovy, which may or may not take parameters and return a value. It is very similar to lambda expressions in Java 8. For example, in the above code it.size() <= 4
and println
it are closures.
Groovy closures have several implicit variables:
it
: If the closure has one argument, it can be referred to