对面的交集在groovy集合 [英] Opposite of intersect in groovy collections
本文介绍了对面的交集在groovy集合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在groovy集合中相交的对面是什么?
what would be the opposite of intersect in groovy collections?
推荐答案
您可能想要结合@Andre和@denis
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 )
denis给出的解决方案将取决于是否
The solution given by denis would depend on whether you do
def opposite = leftCollection-rightCollection // [1,5]
或
def opposite = rightCollection-leftCollection // []
我不认为你想要的
这篇关于对面的交集在groovy集合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文