Hi, I'm a new Groovy user. I am trying to use Groovy in the context of EMF ( www.eclipse.org/emf). This framework includes a utility class ContentTreeIterator which implements Iterator and Iterable at the same time. Clients are supposed to access instances through the Iterator interface. (Using the iterator that's retuned by iterator() will yield different results than using the object itself as the iterator). When I now use each()/eachWithIndex() on instances of this class, the call goes through:
GroovyDefaultMethods: public static <T> Iterable<T> eachWithIndex(Iterable<T> self, @ClosureParams(value=FromString.class, options="T,Integer") Closure closure) { eachWithIndex(self.iterator(), closure); return self; } And I would like it to go directly to: GroovyDefaultMethods: 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; } How can I tackle this? Thanks for your help, Felix