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

make unique() supporting Closures analagous to sort()

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.0-JSR-4
    • 1.0-RC-1
    • groovy-jdk
    • None
    • Patch

    Description

      sort() can take Closures to transparantly wrapping them in to ClosureComparators when they have two parameters and have the standard handling if they take one parameter. unique() has the same demand but only supports Comparators.

      support:

      collection.unique

      { a,b -> a.foo <=> b.foo }

      collection.unique

      { it.foo }

      This need was detected in a corporate IT department using Groovy for gathering Test-Data from a backend system.

      Attachments

        1. Groovy-1236.patch
          1 kB
          codex22
        2. UniqueTest.groovy
          0.8 kB
          codex22

        Activity

          People

            blackdrag Jochen Theodorou
            codevise Dierk König
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: