code: public static <T> T eachWithIndex(T self, Closure closure) {
          final Object[] args = new Object[2];
          int counter = 0;
          for (Iterator iter = InvokerHelper.asIterator(self); iter.hasNext();) {
              args[0] = iter.next();
              args[1] = counter++;
              closure.call(args);
          }
          return self;
      }
docs: Iterates through an aggregate type or data structure,
  passing each item and the item's index (a counter starting at
  zero) to the given closure.
  
  @param self    an Object
  @param closure a Closure to operate on each item
  @return the self Object
  @since 1.0