Encore PTL Encore PTL - 4 months ago 6
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

A filter:

 let farray = arr.filter() {$0 != "b"}