© Adam L. Davis 2019
Adam L. DavisLearning Groovy 3https://doi.org/10.1007/978-1-4842-5058-7_4

4. GDK

Adam L. Davis1 
(1)
New York, NY, USA
 

The GDK (Groovy Development Kit) provides a number of helper methods, 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, arrays, or any Iterable:
  • 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 (similar to the concept of “reduce”).

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

Get Learning Groovy 3: Java-Based Dynamic Scripting 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.