Details
-
New Feature
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.8-beta-1
-
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.