Encore PTL Encore PTL - 1 year ago 87
Swift Question

How to remove an element of a given value from an array in Swift

I want to remove all elements of value x from an array that contains x, y and z elements

let arr = ['a', 'b', 'c', 'b']

How can I remove all elements of value 'b' from arr?

Answer Source

A filter:

 let farray = arr.filter() {$0 != "b"} 
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download