mapIndexed<R> method

KtList<R> mapIndexed<R>(
  1. R transform(
    1. int index,
    2. T
    )
)

Returns a list containing the results of applying the given transform function to each element and its index in the original collection. @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

KtList<R> mapIndexed<R>(R Function(int index, T) transform) {
  final mapped = mapIndexedTo(mutableListOf<R>(), transform);
  // TODO ping dort-lang/sdk team to check type bug
  // When in single line: type "DartMutableList<String>' is not a subtype of type 'Null"
  return mapped;
}