forEach2<Y> method

void forEach2<Y>(
  1. void transformer(
    1. T value,
    2. int index
    )
)

normal forEach with the current index given to you in the transformer

forEach2 is the same as forEach but with the index given to you in the transformer

Implementation

void forEach2<Y>(final void Function(T value, int index) transformer) {
  int index = 0;
  forEach((final T item) {
    transformer(item, index);
    index = index + 1;
  });
}