Groovy Closure
Topics
- What is and why closure?
- Method vs. Closure
- Closure as first-class objects
- Closure parameters & usage of parentheses
- Closure scope
- Method closure operator
- Closure usage areas
What is and Why Closure?
What is a Closure?
- A closure is a chunk of code within {...}
- A closure behaves like a first-class object (just like String or Integer object)
- It can be assigned to a variable (in the same way a String object can be assigned to a variable)
- It can be passed around as a parameter of a method (in the same way a String object can be passed around as a parameter)
- It can be a return value (in the same way a String object can be a return value)
Download course content