associate<R> method
Returns a map that associates values returned by by
with elements in this iterable.
Earlier entries are replaced by later entries if they contain the same key.
This function is a convenience function similar to Map.fromIterable and map comprehension. It is intended for 1:1 mappings. See Group for aggregating several elements by the same key (1:N).
This function is non-deterministic when this iterable is unordered, i.e. HashSet.
final list = [('A'), ('B'), ('C')];
final map = list.associate(by: (foo) => foo.$1);
print(map); // { 'A': ('A'), 'B': ('B'), 'C': ('C') }
Implementation
@useResult Map<R, E> associate<R>({required Select<E, R> by}) => { for (final element in this) by(element): element };