yes, with map mutable. That seems to be what I'm looking for, thanks!
Leon K
02/19/2020, 2:36 PM
or no, it actually isn't. what i'm looking for is this:
Copy code
/** merge another map into this map,
* applying the given remapping function too the two values if there is a key-conflict. */
fun <K, V> MutableMap<K, V>.putAllWith(other: Map<K, V>, remappingFn: (V, V) -> V) = other.forEach { (k, v) ->
merge(k, v, remappingFn)
}
d
Dominaezzz
02/19/2020, 2:42 PM
I don't think that can be done with a single function.
l
Leon K
02/19/2020, 2:42 PM
I guess I'll propose this in the
stdlib
channel then, i've needed it several times and it seems like a good addition!