10.3. Choosing a Collection Method to Solve a Problem
There is a large number of methods available to Scala collections, and you need to choose a method to solve a problem.
The Scala collection classes provide a wealth of methods that can be used to manipulate data. Most methods take either a function or a predicate as an argument. (A predicate is just a function that returns a Boolean.)
The methods that are available are listed in two ways in this recipe. In the next few paragraphs, the methods are grouped into categories to help you easily find what you need. In the tables that follow, a brief description and method signature is provided.
Methods organized by category
- Filtering methods
Methods that can be used to filter a collection include
- Transformer methods
Transformer methods take at least one input collection to create a new output collection, typically using an algorithm you provide. They include
- Grouping methods
These methods let you take an existing collection and create multiple groups from that one collection. These methods include
- Informational and mathematical methods
These methods provide information ...