How to use Groovy Set for unique elements?
Posted
by Guy
on Stack Overflow
See other posts from Stack Overflow
or by Guy
Published on 2010-04-29T19:15:58Z
Indexed on
2010/04/29
21:57 UTC
Read the original article
Hit count: 184
groovy
As simple as this must be I still can't understand where am I wrong:
class A {
boolean equals(o) { true }
}
def s = [new A(), new A()] as Set
assert s.size() == 1 // Assertion failed: actually gives 2
Which method should I override in order to get uniqueness?
© Stack Overflow or respective owner