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)

You must have an active subscription to download PDF,Lab Zip and Recordings of this course topic.Please click the "Subscribe" button or the "Login" button if you already have an account.