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

[ [a:1, b:2, c:3] ].flatten() -> [ 1, 2, 3 ]

    XMLWordPrintableJSON

Details

    • Test
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.6-beta-1
    • 1.5.7
    • groovy-jdk
    • None
    • Originally Run on OS-X
    • Patch

    Description

      The JavaDoc of flatten says: "This collection and any nested collections have their contents (recursively) added to the new collection." However, if it encounters a map, it exacts the value list and flattens that. This is odd on two points – 1) a Map is not a Collection, so it shouldn't be touched by #flatten according to that definition, and 2) there is no map#flatten which corresponds to this behavior.

      This makes it sound like a bug to me, but there may be existing code dependent on the issue. So the attached patches just document and demonstrate the issue.

      Attachments

        1. DefaultGroovyMethods.java.docupdate.patch
          0.4 kB
          Robert Fischer
        2. DefaultGroovyMethodsTest.java.docupdate.patch
          6 kB
          Robert Fischer

        Issue Links

          Activity

            People

              paulk Paul King
              robertfischer Robert Fischer
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: