You are previewing Scala for the Impatient.

Scala for the Impatient

Cover of Scala for the Impatient by Cay S. Horstmann Published by Addison-Wesley Professional

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 ...

The best content for your career. Discover unlimited learning on demand for around $1/day.