IterableCommonExtension<T> extension
Common extensions for Iterable
- on
-
- Iterable<
T>
- Iterable<
Properties
- firstOrNull → T?
-
Returns the first element.
no setter
- lastOrNull → T?
-
Returns the last element.
no setter
-
notNull
→ Iterable<
T> -
Returns
this
iterable without anynull
values within this Iterable.no setter - singleOrNull → T?
-
Checks that this iterable has only one element, and returns that element.
no setter
Methods
-
firstOrNullWhere(
bool test(T element)) → T? -
Returns the first element that satisfies the given predicate
test
. -
group<
K> (K by(T item)) → Map< K, List< T> > -
Groups Iterable via
K by(T item)
-
groupMap<
K, V> (K by(T item), V as(List< T> item)) → Map<K, V> -
Groups Iterable via
K by(T item)
and maps it usingV as(List<T> item)
conversion. -
lastOrNullWhere(
bool test(T element)) → T? -
Returns the last element that satisfies the given predicate
test
. -
mapList<
E> (E f(T e)) → List< E> - Maps Iterable and casts it to a List.
-
mapWhereList<
E> (E f(T e), bool test(E element)) → List< E> - Maps Iterable, then filters Iterable and then casts it to a List.
-
singleOrNullWhere(
bool test(T element)) → T? -
Returns the single element that satisfies
test
. -
whereList(
bool test(T element)) → List< T> - Filters Iterable and casts it to a List.
-
whereMapList<
E> (bool test(T element), E f(T e)) → List< E> - Filters Iterable, then mapps Iterable and then casts it to a List.