Chapter 4Working with Scala Collections
by Venkat Subramaniam
In the preceding chapter, we looked at the object-oriented side and the functional side of Scala. These two programming styles interplay powerfully in collections—and that’s what we’ll see in this chapter.
A direct look at the Scala collections hierarchy[1] can be overwhelming. But when distilled down, each Scala collection can be viewed as belonging to one of two categories: immutable or mutable. Some Scala collections are also lazy (read: efficient).
For starters, in both the immutable and mutable flavors, Scala provides implementations of Seq, Set, and Map. Seqs (lists) are ordered collections, sets are unordered, and maps are collections of key-value pairs.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access