I need confirmation of something not documented an...
# announcements
r
I need confirmation of something not documented anywhere:
Copy code
myMutableMap.values.removeAll { <predicate> }
Will this remove entries from the map?
a
Yep. Kotlin mutableMapOf is backed by java.util.LinkedHashMap. LinkedHashMap.values() documentation says:
Returns a Collection view of the values contained in this map. The collection is backed by the map, so changes to the map are reflected in the collection, and vice-versa.
h
... so it really depends on your predicate: for
.removeAll { false }
, the answer to your question is no. 😄
r
So it depends on the map implementation, that's why it isn't documented in MutableMap