Reputation: 35050
ipsToReload.filter { !contains(self.ipsToInsert, {$0.row == $1.row}) }
I want to get this expression work. I need complements of the two generic array: ipsToReload
\ ipsToInsert
. Any idea what I am doing wrong?
This is the definition:
var ipsToInsert = [NSIndexPath]()
var ipsToDelete = [NSIndexPath]()
Upvotes: 1
Views: 70
Reputation: 40965
The trouble is that you have two nested closure expressions (the one to filter
, and the one to contains
). But within a closure expression, $0
and $1
refer to arguments local to that closure expression – so in this case, you are writing an expression for contains
that takes two arguments ($0
and $1
), and then the closure argument to filter
looks as if it takes no arguments (hence Swift is complaining that you can't pass a ()->_
argument into filter
).
Try naming the arguments, like so:
ipsToReload.filter { reload in
!contains(ipsToInsert) { insert in
reload.row == insert.row
}
}
Upvotes: 2