Groovy
  1. Groovy
  2. GROOVY-4335

Set doesn't consider equals() method

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Not A Problem
    • Affects Version/s: 1.7.4
    • Fix Version/s: 1.7.4
    • Component/s: None
    • Labels:
      None

      Description

      //  the Card class has equals() method implemented, so this works:
      assert new Card("6s") == new Card("6s")
      
      //  here's a list with 3 equal cards:
      def list = ["4c", "6s", "6s", "6s", "6c"].collect {new Card(it)}
      
      //  since three cards are equal, the following is pretty much expected:
      assert list.clone().unique().size() == 3
      
      //  but Set doesn't recognize cards as equal:
      assert (list as Set).size() == 5
      

      Since Set's definition states that it's an unordered collection of unique items, and all other statements prove that three items of this collection are not unique, I believe it's a bug.

        Activity

        Nikita Y Volkov created issue -
        Nikita Y Volkov made changes -
        Field Original Value New Value
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Fix Version/s 1.7.4 [ 16563 ]
        Paul King made changes -
        Resolution Fixed [ 1 ]
        Status Resolved [ 5 ] Reopened [ 4 ]
        Paul King made changes -
        Status Reopened [ 4 ] Resolved [ 5 ]
        Resolution Not A Bug [ 6 ]
        Paul King made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Mark Thomas made changes -
        Project Import Sun Apr 05 13:32:57 UTC 2015 [ 1428240777691 ]
        Mark Thomas made changes -
        Workflow jira [ 12733276 ] Default workflow, editable Closed status [ 12745045 ]
        Mark Thomas made changes -
        Project Import Mon Apr 06 02:11:23 UTC 2015 [ 1428286283443 ]
        Mark Thomas made changes -
        Workflow jira [ 12970852 ] Default workflow, editable Closed status [ 12978630 ]

          People

          • Assignee:
            Unassigned
            Reporter:
            Nikita Y Volkov
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development