Collections

Five lessons on the collections a Groovy program lives in: the list literal and its indexes, the map with property access, the set and the range, the GDK methods that replace most loops, and the spread operator, the subscript and the typed collection.

4.1 Lists the literal, indexing, negative indexes, adding and removing, and the list a method returns Open 4.2 Maps map literals, property access, defaults, iteration and the sorted output Open 4.3 Sets and ranges a set as a collection without duplicates, and a range as a lazy list Open 4.4 The GDK methods collect, findAll, inject, groupBy, sort, unique, sum, take and drop on one list Open 4.5 Spread, subscript and generics the spread operator, the subscript assignment, immutable views and typed collections Open

Lessons