mapIndexedTo<R> method

List<R> mapIndexedTo<R>(
  1. List<R> destination,
  2. R transform(
    1. int,
    2. T
    )
)

Applies the given transform function to each element and its index in the original collection and appends the 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

List<R> mapIndexedTo<R>(List<R> destination, R Function(int, T) transform) {
  var index = 0;
  for (var item in this) {
    destination.add(transform(index++, item));
  }
  return destination;
}