mapNotNullTo<R, C extends KtMutableCollection<R>> method

C mapNotNullTo<R, C extends KtMutableCollection<R>>(
  1. C destination,
  2. R? transform(
    1. T
    )
)

Applies the given transform function to each element in the original collection and appends only the non-null results to the given destination.

Implementation

C mapNotNullTo<R, C extends KtMutableCollection<R>>(
    C destination, R? Function(T) transform) {
  for (final item in iter) {
    final result = transform(item);
    if (result != null) {
      destination.add(result);
    }
  }
  return destination;
}