mapIndexedNotNull<R> method

Iterable<R> mapIndexedNotNull<R>(
  1. R? transform(
    1. int index,
    2. E
    )
)

Returns a new lazy Iterable containing only the non-null results of applying the given transform function to each element and its index in the original collection.

Implementation

Iterable<R> mapIndexedNotNull<R>(R? Function(int index, E) transform) sync* {
  var index = 0;
  for (final element in this) {
    final result = transform(index++, element);
    if (result != null) {
      yield result;
    }
  }
}