条件に当てはまらない要素を取得する(notFindAllの実装)

条件に当てはまらない要素を取得する。
第4回 もくもくGroovy(http://bit.ly/ol8SDW)の成果はこれだけか…

条件に当てはまらない要素を取得する。
第4回 もくもくGroovy(http://bit.ly/ol8SDW)の成果はこれだけか…

  • タグ:
  • タグはありません
Collection.metaClass.notFindAll = { clos ->
  delegate.groupBy(clos)[false]
}

def condition = { it == 2 }
def list = [1, 2, 3]
assert [2] == list.findAll(condition)
assert [1, 3] == list.notFindAll(condition)