code: public static <T> Iterator<T> eachWithIndex(Iterator<T> self, @ClosureParams(value=FromString.class, options="T,Integer") Closure closure) {
          final Object[] args = new Object[2];
          int counter = 0;
          while (self.hasNext()) {
              args[0] = self.next();
              args[1] = counter++;
              closure.call(args);
          }
          return self;
      }
docs: Iterates through an iterator type,
  passing each item and the item's index (a counter starting at
  zero) to the given closure.
  
  @param self    an Iterable
  @param closure a Closure to operate on each item
  @return the self Iterable
  @since 2.3.0