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

minus(List, Collection) considers different objects equal if they have equal hashCode's

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • None
    • None
    • groovy-jdk
    • None
    • Groovy++ which IMO doesn't matter

    Description

      class Foo {
        int hashCode() { 42 }
      }
      
      def x = [new Foo()]
      def y = [new Foo()]
      
      println (x-y) // prints []
      x.removeAll(y)
      println x // prints [Foo@2a]
      

      Not sure about released Groovy versions. NumberAwareComparator seems to be responsible

      Attachments

        Activity

          People

            paulk Paul King
            gromopetr Peter Gromov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: