How to use Groovy Set for unique elements? -


as simple must still can't understand wrong:

class {     boolean equals(o) { true } } def s = [new a(), new a()] set assert s.size() == 1 // assertion failed: gives 2 

which method should override in order uniqueness?

hashcode, java

class {     boolean equals(o) { true }     int hashcode() { 1 } } def s = [new a(), new a()] set assert s.size() == 1 

Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -