How to add or update entries in an immutable Map in Scala

Hey there!

Welcome to

In this post, we will look at a Scala program to add or update entries in a Map.

we can use “+” method on the map instance to add/update elements. If called this method with an existing key, the corresponding value gets updated. If called with new key, the entry gets added to the Map.

Let’s look at a simple program for demonstration:


Happy learning.

Please leave a reply in case of any queries.

Leave a Reply

Your email address will not be published.