Programming in Scala [Chapter 17] — Collections

Tom van Eijk
7 min readDec 3, 2023
Photo by Clem Onojeghuo on Unsplash

Introduction

This is part of my personal reading summary of the book — Programming in Scala. Take into account, we use Scala 2 since it is in industry and has vastly more resources available than Scala 3.

In Scala, a diverse collections library includes arrays, lists, sets, and maps. This chapter provides an overview of their relationships in the inheritance hierarchy. Additionally, it introduces various less common collection types, discussing tradeoffs in terms of speed, space, and input data requirements. The sections are as follows:

  1. Overview of the library
  2. Sequences
  3. Sets and maps
  4. Selecting mutable versus immutable collections
  5. Initializing collections
  6. Tuples

1. Overview of the library

The Scala collections library includes various classes and traits. Key traits in the hierarchy are Iterable . Iterable is the supertrait of sequences (Seqs), sets, and maps. Sequences are ordered collections such as arrays and lists, sets contain unique objects, and maps associate keys with values.

--

--

Tom van Eijk

Data Enthusiast who loves to write data engineering blogs for learning purposes