associate<K, V> method

  1. @useResult
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

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