associate<K, V> method

KtMap<K, V> associate<K, V>(
  1. KtPair<K, V> transform(
    1. T
    )
)

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

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 collection.

Implementation

KtMap<K, V> associate<K, V>(KtPair<K, V> Function(T) transform) {
  final map = associateTo(linkedMapFrom<K, V>(), transform);
  // TODO ping dort-lang/sdk team to check type bug
  // When in single line: type 'DartLinkedHashMap<String, String>' is not a subtype of type 'Null'
  return map;
}