Opposite of intersect in groovy collections
问题 what would be the opposite of intersect in groovy collections? 回答1: 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