[ 
https://issues.apache.org/jira/browse/GROOVY-10682?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17611701#comment-17611701
 ] 

Felix Schnabel edited comment on GROOVY-10682 at 9/30/22 7:14 PM:
------------------------------------------------------------------

I've implemented {{any}}, {{chop}}, {{each}} and {{eachWithIndex}} in the new 
{{ArrayGroovyMethods}} and included test cases in the javadoc that check that 
it compiles with STC.
I also brought the primitive versions of {{count}}, {{sum}}, {{average}}, 
{{join}}, {{getIndices}}, {{asBoolean}}, {{equals}}, {{toString}} and 
{{eachByte}} to {{ArrayGroovyMethods}} and mark the old method as deprecated.
The method {{asType}} already worked also for primitive types, so I dont think 
we need the extra variants.
{code:groovy}
@groovy.transform.TypeChecked
void test(){
    boolean[] x = new boolean[]{false}
    print x.asType(List.class)
}
test()
{code}
What are widely used methods, that should also be brought over in this first 
iteration?


was (Author: JIRAUSER295331):
I've implemented {{any}}, {{chop}}, {{each}}and {{eachWithIndex}}in the new 
{{ArrayGroovyMethods}}.
I also included test cases in the javadoc that check that it compiles with STC.
The method {{asType}} already worked also for primitive types, so I dont think 
we need the extra variants.
{code:groovy}
@groovy.transform.TypeChecked
void test(){
    boolean[] x = new boolean[]{false}
    print x.asType(List.class)
}
test()
{code}
What are widely used methods, that should also be brought over in this first 
iteration? And what about {{eachByte}}, should it just stay in 
{{DefaultGroovyMethods}}?

> 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)

Reply via email to