what would be the opposite of intersect in groovy collections?
You probably want to combine both the answers from @Andre and @denis
I think what you want is the union and then subtract the intersection from this
def a = [1,2,3,4,5] def b = [2,3,4] assert [1,5] == ( a + b ) - a.intersect( b )
The solution given by denis would depend on whether you do
def opposite = leftCollection-rightCollection // [1,5]
or
def opposite = rightCollection-leftCollection // []
which I don't think you wanted
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With