mapNotNull<R> method

  1. @useResult
KtList<R> mapNotNull<R>(
  1. R? transform(
    1. T
    )
)

Returns a list containing the results of applying the given transform function to each element in the original collection.

Implementation

@useResult
KtList<R> mapNotNull<R>(R? Function(T) transform) {
  final destination = mutableListOf<R>();
  for (final item in iter) {
    final result = transform(item);
    if (result != null) {
      destination.add(result);
    }
  }
  return destination;
}