associateTo

inline suspend fun <E, K, V, M : MutableMap<in K, in V>> ReceiveChannel<E>.associateTo(
    destination: M,
    transform: (E) -> Pair<K, V>
): M
(source)

Platform and version requirements: JVM

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

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

The operation is terminal. This function consumes all elements of the original ReceiveChannel.