36 Map

After reading this lesson, you will be able to

  • Define a key-value structure, called Map
  • Add and remove entries to Map
  • Compute the union and difference of two Maps
  • Manipulate the elements of a key-value structure using the map and flatMap functions
  • Chain multiple instances using for-comprehension

In the previous lesson, you mastered the operations you can perform on a set. In this lesson, you’ll discover a new data structure called Map. In Scala, Map is an immutable data structure to store a set of keys, each of them associated with a value. The concept of mapping keys to values is not unique to the Scala language; some languages, such as Java, refer to it using the term hashmap; others, such as Python, call it dictionary. You’ll create ...

Get Get Programming with Scala now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.