https://kotlinlang.org logo
Title
r

ribesg

04/02/2018, 12:31 AM
I need confirmation of something not documented anywhere:
myMutableMap.values.removeAll { <predicate> }
Will this remove entries from the map?
a

Alexander Mikhalchenko

04/02/2018, 5:53 AM
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

hallvard

04/02/2018, 10:20 AM
... so it really depends on your predicate: for
.removeAll { false }
, the answer to your question is no. 😄
r

ribesg

04/02/2018, 11:50 AM
So it depends on the map implementation, that's why it isn't documented in MutableMap