APPENDIX J ADVANCED CLOSURES
Chapter 9 introduced closures as parametric code blocks that can be referenced and passed as method parameters. An important example of the latter was closures given as parameters to methods that iterated through collections. We saw how methods such as each and findAll can be used to describe some processing to be performed on all the elements of a collection.
In this appendix, we further explore closures by observing that they can also be returned from methods or from other closures. Closures as return values from other closures provide a very powerful framework that can be applied to a variety of problems. For example, we may wish to define the constraints that apply to individual objects, the relationships that ...
Get Groovy Programming now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.