associate

inline suspend fun <E, K, V> ReceiveChannel<E>.associate(
    transform: (E) -> Pair<K, V>
): Map<K, V>
(source)

Platform and version requirements: JVM

Returns a Map containing key-value pairs provided by transform function applied to elements of the given channel.

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

The returned map preserves the entry iteration order of the original channel.

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