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

Set doesn't consider equals() method

    Details

    • Type: Bug
    • Status: Closed
    • Priority: 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.

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved: