Chapter 4. Maps and Tuples

Topics in This Chapter image

4.1 Constructing a Map — page 41

4.2 Accessing Map Values — page 42

4.3 Updating Map Values — page 43

4.4 Iterating over Maps — page 43

4.5 Sorted Maps — page 44

4.6 Interoperating with Java — page 44

4.7 Tuples — page 45

4.8 Zipping — page 46

Exercises — page 46

A classic programmer’s saying is, “If you can only have one data structure, make it a hash table.” Hash tables—or, more generally, maps—are among the most versatile data structures. As you will see in this chapter, Scala makes it particularly easy to use them.

Maps are collections of key/value pairs. Scala has a general ...

Get Scala for the Impatient now with O’Reilly online learning.

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