根据另一个列表的键值过滤列表

时间:2014-04-02 10:04:40

标签: groovy

我有两个列表

list1 = [ [ key1:'value1', key2:'value2', key3:'value3' ],
          [ key1:'value4', key2:'value5', key3:'value6' ] ]
list2 = [ [ key1:'value10', key2:'value2', key3:'value11' ],
          [ key1:'value7',  key2:'value8', key3:'value9'  ] ]

我想在list1 key2 = list2 key2时删除list1中的条目,即value2 here

1 个答案:

答案 0 :(得分:0)

你应该可以这样做:

List filteredList1 = list1.findAll { !list2.key2.contains( it.key2 ) }