Chapter 17


Scala has a rich collection library. This chapter gives a tour of the most commonly used collection types and operations, showing just the parts you will use most frequently. Chapter 24 will give a more comprehensive tour of what's available, and Chapter 25 will show how Scala's composition constructs are used to provide such a rich API.

17.1 Sequences

Sequences types let you work with groups of data lined up in order. Because the elements are ordered, you can ask for the first element, second element, 103rd element, and so on. In this section, we'll give you a quick tour of the most important sequences.


Perhaps the most important sequence type to know about is class List, the immutable linked-list described in ...

Get Programming in Scala, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.