associateWith<V> method

KtMap<T, V> associateWith<V>(
  1. V valueSelector(
    1. T
    )
)

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.

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

Implementation

KtMap<T, V> associateWith<V>(V Function(T) valueSelector) {
  final associated = associateWithTo(linkedMapFrom<T, V>(), valueSelector);
  // TODO ping dort-lang/sdk team to check type bug
  // When in single line: type "DartMutableList<String>' is not a subtype of type 'Null"
  return associated;
}