associateTo<K, V, M extends KtMutableMap<K, V>> method

M associateTo<K, V, M extends KtMutableMap<K, V>>(
  1. M destination,
  2. KtPair<K, V> transform(
    1. T
    )
)

Populates and returns the destination mutable map with key-value pairs provided by transform function applied to each element of the given collection.

If any of two pairs would have the same key the last one gets added to the map.

Implementation

M associateTo<K, V, M extends KtMutableMap<K, V>>(
    M destination, KtPair<K, V> Function(T) transform) {
  for (final element in iter) {
    final pair = transform(element);
    destination.put(pair.first, pair.second);
  }
  return destination;
}