O'Reilly logo

Learning Groovy by Adam L. Davis

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

© Adam L. Davis 2016

Adam L. Davis, Learning Groovy, 10.1007/978-1-4842-2117-4_4

4. GDK

Adam L. Davis

(1)New York, USA

The GDK (Groovy Development Kit ) provides a number of helper methods, helper operators, utilities, and additional classes.

Some of these are methods added to every Java class, like each, and some are more obscure.

Collections

Groovy adds tons of helpful methods that allow easier manipulation of collections:

  • sort—Sorts the collection (if it is sortable).

  • findAll—Finds all elements that match a closure.

  • collect—An iterator that builds a new collection.

  • inject—Loops through the values and returns a single value.

  • each—Iterates through the values using the given closure.

  • eachWithIndex—Iterates through with two parameters: a value and ...

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