mapIndexedNotNullTo<R, C extends KtMutableCollection<R> > method
C
mapIndexedNotNullTo<R, C extends KtMutableCollection<R> >(
- C destination,
- R? transform(
- int index,
- T?
Applies the given transform
function to each element and its index in the original collection
and appends only the non-null results to the given destination
.
@param transform
function that takes the index of an element and the element itself
and returns the result of the transform applied to the element.
Implementation
C mapIndexedNotNullTo<R, C extends KtMutableCollection<R>>(
C destination, R? Function(int index, T?) transform) {
var index = 0;
for (final item in iter) {
final element = transform(index++, item);
if (element != null) {
destination.add(element);
}
}
return destination;
}