mergeTo

fun <K, V, D : MutableMap<in K, in V>> mergeTo(map1: Map<out K, V>, map2: Map<out K, V>, destination: D): D

Merges the first map and the second map prioritising the second one, 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 from the second map is chosen.

Return

the destination.

Parameters

map1

the first (less prioritised) map to merge.

map2

the second (more prioritised) map to merge.

destination

the map where result of the merge is put.