distinctBy<K> method

Iterable<E> distinctBy<K>(
  1. K selector(
    1. E element
    )
)

Returns a Iterable containing only elements from the given collection having distinct keys returned by the given selector function.

Implementation

Iterable<E> distinctBy<K>(K Function(E element) selector) {
  final set = <K>{};

  return where((element) => set.add(selector(element)));
}