[
https://issues.apache.org/jira/browse/GROOVY-10682?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17609132#comment-17609132
]
Felix Schnabel edited comment on GROOVY-10682 at 9/25/22 10:43 AM:
-------------------------------------------------------------------
So I added the new ArrayGroovyMethods class and moved all each and
eachWithIndex methods to it. I made the old versions in DefaultGroovyMethods
reference the new one and add a deprecation annotation. While refactoring I
noticed that there also exists eachByte(byte[] self, Closure closure) and
eachByte(Byte[] self, Closure closure) which just call each.
https://github.com/apache/groovy/blob/master/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L17322-17344
Should those also be moved and placed next to the each methods?
was (Author: JIRAUSER295331):
So, I added the new ArrayGroovyMethods class and moved all each and
eachWithIndex methods to it. I made the old versions in DefaultGroovyMethods
reference the new one and add a deprecation annotation. While refactoring I
noticed that there also exists eachByte(byte[] self, Closure closure) and
eachByte(Byte[] self, Closure closure) which just call each.
https://github.com/apache/groovy/blob/master/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L17322-17344
Should those also be moved and placed next to the each methods?
> Provide eachWithIndex for primitive arrays
> ------------------------------------------
>
> Key: GROOVY-10682
> URL: https://issues.apache.org/jira/browse/GROOVY-10682
> Project: Groovy
> Issue Type: Improvement
> Components: groovy-jdk
> Reporter: Eric Milles
> Assignee: Eric Milles
> Priority: Minor
>
> Consider the following:
> {code:groovy}
> @groovy.transform.TypeChecked
> void test(int[] ints) {
> ints.eachWithIndex { value, index ->
> println "$index: ${value.doubleValue()}"
> }
> }
> test(0,1,2,3,4,5)
> {code}
> Compiler reports "[Static type checking] - Cannot find matching method
> java.lang.Object#doubleValue()"
> {{eachWithIndex}} is only provided for reference types, so "value" is seen as
> Object by the type checker.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)