This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 11.15, “How to Add, Update, and Remove Elements with a Mutable Map”
You want to add, remove, or update elements in a mutable map.
Add elements to a mutable map by simply assigning them, or with the
+= method. Remove elements with
--=. Update elements by reassigning them.
Given a new, mutable