O'Reilly logo

Groovy and Grails Recipes by Bashar Abdul-Jawad

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

CHAPTER 5Closures

You have already seen some examples of closures in previous chapters. The concept of closures is new to most Java developers, and closures might seem a bit foreign when you see them for the first time. By working your way through the examples in this chapter, you will get a much better understanding of closures, how they work, and how to use them efficiently. Closures are important in Groovy; almost any real-life example in Groovy will use closures, and a good understanding of them is essential if you want to get the most out of the language.

5-1. What Is a Closure?

A closure is simply an anonymous block of code. The most important thing you need to know about closures is that they are objects of type groovy.lang.Closure: you ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required