mergeToBy
inline fun <K, V1 : W, V2 : W, W, D : MutableMap<K, W>> mergeToBy(map1: Map<out K, V1>, map2: Map<out K, V2>, destination: D, resolve: (key: K, value1: V1, value2: V2) -> W): D
Merges the first map and the second map resolving conflicts with resolve lambda, puts result to the destination and returns the destination.
Precisely, corresponding keys and values of the received maps are put into the destination overriding existing values in the destination if needed. For every key appearing in both maps corresponding value is a result of the resolve lambda calculated on the key and its corresponding values from the merged maps.
Return
the destination.
Parameters
map1
the first map to merge.
map2
the second map to merge.
resolve
lambda function that resolves merge conflicts.
destination
the map where the result of the merge is put.