Chapter 11. Collections: Introduction
This is the first of five chapters that cover the Scala collections classes. Because collections are so important to any programming language, these chapters provide in-depth coverage of Scala’s collections classes and methods. Furthermore, these chapters have been completely reorganized in this second edition of the Scala Cookbook to make the recipes easier for you to find.
This first collections chapter provides an introduction to the collections classes. The intent of this chapter is to demonstrate how the classes are organized, and to help you choose a collections class for your needs. For example, if you want an indexed, immutable sequence, Vector
is recommended as the go-to sequence, but if you want an indexed, mutable sequence, ArrayBuffer
is recommended instead.
After this chapter, Chapter 12 covers the most commonly used Scala sequence classes, including Vector
, ArrayBuffer
, List
, and Array
. Additional recipes cover ListBuffer
and LazyList
.
Chapter 13 provides recipes for the most common methods that are available on the Scala sequence classes. The collections classes are well known for the depth of the built-in methods that are available, and that chapter demonstrates those methods.
Chapter 14 covers the Map
types. Scala maps are like the Java Map
, Ruby Hash
, or Python dictionary, in that they consist of key/value pairs, where the key must be unique. Scala has both immutable and mutable maps, and they’re both covered in this chapter. ...
Get Scala Cookbook, 2nd Edition 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.