onEachIndexed method

KtSet<T> onEachIndexed(
  1. void action(
    1. int index,
    2. T item
    )
)

Performs the given action on each element, providing sequential index with the element, and returns the collection itself afterwards.

Implementation

KtSet<T> onEachIndexed(void Function(int index, T item) action) {
  var index = 0;
  for (final item in iter) {
    action(index++, item);
  }
  return this;
}