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

Does/could Groovy support multiple variable definitions in for loop?

    Details

    • Type: Question
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.6.0-alpha-1
    • Component/s: Compiler
    • Labels:
      None

      Description

      I ask this because it has been causing a lot of headaches when we convert Java files to Groovy. This form seems to fail and seems reasonably useful:

      for (int i = 0, n = list.length; i < n; i +=1) {
      

      It seems the definition of two or more variables in the for initializer is not supported.

        Activity

        Hide
        jwagenleitner John Wagenleitner added a comment -

        I believe this is supported in the anltr4 "parrot" branch that is planned for an upcoming major release.

        https://github.com/apache/groovy/blob/35ec2156e3356f85a666c71ba3d3df3bf74c81ae/subprojects/groovy-parser-antlr4/src/test/resources/core/For_05x.groovy

        Show
        jwagenleitner John Wagenleitner added a comment - I believe this is supported in the anltr4 "parrot" branch that is planned for an upcoming major release. https://github.com/apache/groovy/blob/35ec2156e3356f85a666c71ba3d3df3bf74c81ae/subprojects/groovy-parser-antlr4/src/test/resources/core/For_05x.groovy
        Hide
        daniel_sun Daniel Sun added a comment -

        As John found, the improvement has been completed in the parrot branch.

        Show
        daniel_sun Daniel Sun added a comment - As John found, the improvement has been completed in the parrot branch.

          People

          • Assignee:
            daniel_sun Daniel Sun
            Reporter:
            emilles Eric Milles
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development