[
https://issues.apache.org/jira/browse/GROOVY-10682?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17609061#comment-17609061
]
Felix Schnabel commented on GROOVY-10682:
-----------------------------------------
I would have some questions about the new `ArrayGroovyMethods` approach:
# This class should be contained in the same folder as `DefaultGroovyMethods`
and also extend `DefaultGroovyMethodsSupport`? Is there anything else that
needs to be done that the methods defined in this class are available at groovy
runtime?
# Should each instance of `each` that works with lists or arrays be moved to
this new class (`each` on maps would still stay in `DefaultGroovyMethods`)?
There are currently:
## each(T[] self, Closure closure) -> move
## each(primitive[] self, Closure closure) -> move
## each(T self, Closure closure) -> move?
## each(Iterable<T> self, Closure closure) -> move?
## each(Iterator<T> self, Closure closure) -> move?
## each(Collection<T> self, Closure closure) -> don't move?
## each(List<T> self, Closure closure) -> don't move?
## each(Set<T> self, Closure closure) -> don't move?
## each(SortedSet<T> self, Closure closure) -> don't move?
## each(Map<K, V> self, Closure closure) -> don't move
I would still write the hand coded primitive extensions with the actual
implementation (option 1) since it is the most efficient unless you want prefer
one of the other options.
> 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)