Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-10682

Provide eachWithIndex for primitive arrays

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 5.0.0-alpha-1
    • groovy-jdk
    • None

    Description

      Consider the following:

      @groovy.transform.TypeChecked
      void test(int[] ints) {
        ints.eachWithIndex { value, index ->
          println "$index: ${value.doubleValue()}"
        }
      }
      test(0,1,2,3,4,5)
      

      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.

      Attachments

        Issue Links

          Activity

            People

              emilles Eric Milles
              emilles Eric Milles
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: