|
|
|
|
|
by xmcqdpt2
1118 days ago
|
|
There is no additional programming complexity in using Scala's Map vs Java's HashMap. They are both maps with keys and values. The Java one you update in-place var m = new HashMap<K,V>()
m.add(k, v)
the Scala one you "update" by creating new maps, var m = Map.empty[K, V]
m += (key, value)
In practice it's mostly the same except you can share the immutable one around without being scared someone will mutate it, but it takes more memory per instance than the mutable version and creates more GC churn, which may or may not be an issue. |
|