You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by GitBox <gi...@apache.org> on 2022/09/21 15:07:32 UTC

[GitHub] [groovy] eric-milles commented on a diff in pull request #1785: GROOVY-10682: Provide eachWithIndex for primitive arrays

eric-milles commented on code in PR #1785:
URL: https://github.com/apache/groovy/pull/1785#discussion_r976633838


##########
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:
##########
@@ -2273,6 +2273,26 @@ public static <T> T[] eachWithIndex(T[] self, @ClosureParams(value=FromString.cl
         return self;
     }
 
+    /**
+     * Iterates through an int[],
+     * passing each int and the element's index (a counter starting at
+     * zero) to the given closure.
+     * <pre class="groovyTestCase">
+     * int result = 0
+     * [0, 1, 2].eachWithIndex{ x, index {@code ->} result += x * index }

Review Comment:
   Please ensure that the object expression is of type `int[]` to test the annotated method.  This is `List<Integer>` and so it tests another `eachWithIndex` veriant.  You can debug `MainJavadocAssertionTest` to see if your addition is hit by any test cases.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@groovy.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org