code: public static <T> T[] eachWithIndex(T[] self, @ClosureParams(value=FromString.class, options="T,Integer") Closure closure) {
          final Object[] args = new Object[2];
          int counter = 0;
          for(T item : self) {
              args[0] = item;
              args[1] = counter++;
              closure.call(args);
          }
          return self;
      }
docs: Iterates through an array,
  passing each array element and the element's index (a counter starting at
  zero) to the given closure.
  <pre class="groovyTestCase">
  String[] letters = ['a', 'b', 'c']
  String result = ''
  letters.eachWithIndex{ letter, index {@code ->} result += "$index:$letter" }
  assert result == '0:a1:b2:c'
  </pre>
  
  @param self    an array
  @param closure a Closure to operate on each array entry
  @return the self array
  @since 2.5.0