Containment Containment - 1 year ago 52
Swift Question

How can I filter an array to make sure it does contain positions of another array

I am filtering my array in the following way:

randomArray = randomArray.filter({m in m.x < firstArray[0].x && ConditionX})

I have a another array
which contains a elements which are in
I would like to add another condition (to represent
in the code above) to the filter to remove all positions in

Answer Source

Despite not understand exactly what you're trying to do here's a swing at basic array filtering.

let array1 = ["a", "b", "c"]
let array2 = ["c", "d", "e"]
var array3 = array1.filter() { return !array2.contains($0) }

That should return:

["a", "b"]
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download