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?
That's the expected behavior. HashMap is most useful as a specific implementation of Map involving 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' immutable Map.
Do you have a reason for your code to know that it's a HashMap after you've new'd it as above?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With