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

Oddity with Min function for Collections

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.4.0-beta-3
    • Component/s: None
    • Labels:
      None

      Description

      Consider the following array:

      arr = [3,null,5]

      Calling min() on this array results in the value 3. However, using min with a closure as in...

      arr.min

      { it }

      will result in the value of 5. Groovy basically ignores everything prior to and including the null.

      Someone first detected this problem a couple of years ago, but it still doesn't appear to be fixed. Here is the original thread on this:

      http://groovy.329449.n5.nabble.com/Oddity-with-Groovy-Collection-min-when-using-a-closure-td5710629.html

        Attachments

          Activity

            People

            • Assignee:
              paulk Paul King
              Reporter:
              onevim Vimal Gopal
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: