I am having problems using the update method of scala.collection.immutable.HashMap.I don’t see the reason it returns a Map instead of a HashMap. How do I get a new HashMap with a new key-value pair added?
I am having problems using the update method of scala.collection.immutable.HashMap.I don’t see the reason
Share
That’s the expected behavior.
HashMapis most useful as a specific implementation ofMapinvolving using a hash table for lookups.Usually, you’d say
var values: Map[String, Any] = new HashMap, and then sit back and use it as if it’s a plain ol’ immutableMap.Do you have a reason for your code to know that it’s a HashMap after you’ve
new‘d it as above?