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

Groovy equality for Sets and Maps

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.8-beta-1
    • 1.8-beta-1
    • groovy-jdk
    • None

    Description

      Currently, Groovy equality extends to arrays and lists, but not to sets and maps. Example:

      assert [1] == [1L] // passes
      assert [1] as Set == [1L] as Set // fails
      

      This is surprising and ungroovy. It would be nice to have Groovy equality for sets and maps too. The drawback is that it would make set/map equality inconsistent with lookup results (i.e. two sets are equal but Set.contains() yields different results). On the other hand, the same problem already exists for Groovy list equality. For maps, one could avoid the (lookup) inconsistency by only using Groovy equality for values. It would be good to have a discussion about this proposal.

      Attachments

        Activity

          People

            paulk Paul King
            pniederw Peter Niederwieser
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: