© 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 ...

Get Learning Groovy 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.