>
> If I define intersect like this:
> A intersect B = C:
> x element of A and x element of B is equivalent to x element of C
>
> with A,B,C not being Sets, just similar, then I don't see why repetition
> should not be allowed in the result. If somebody wants no repetition,
> then he should use sets or unique.
>
I have a different take on this. I think intersect() is by definition a set
operation and the method on Iterable is simply a convenience that
automatically converts the object and the arguments to sets. I would even
argue for the result of the method always being a set as well.
Even if one doesn't agree with this definition, the current implementation
is broken. Surely intersect() must be a commutative operation? And yet this
code
def a = [1, 1, 2, 4]
def b = [1, 2, 2, 3]
a.intersect(b)
produces a result of [1, 2, 2]. b.intersect(a) produces [1, 1, 2].
I'll raise an issue on which further discussion can take place.
Cheers,
Peter