assocWith

inline fun <K, V> Iterable<K>.assocWith(valueSelector: (K) -> V): Map<K, V>
inline fun <K, V> Sequence<K>.assocWith(valueSelector: (K) -> V): Map<K, V>

Returns a Map where keys are elements from the given collection and values are produced by the valueSelector function applied to each element.

If any two elements are equal, the last one gets added to the map and the method creates a warning.

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