Removing elements in an array using Swift 4.0

February 03, 2019

A useful task to perform is to remove a specific element of an array. There are usually two approaches to this, you can determine the index and remove that index from the array or you can use the filter function in swift.

var developers = ["Eliad", "Alex", "Tim", "Francesco"]

developers.remove(at: 2)  //["Eliad", "Alex", "Francesco"]
var developers = ["Eliad", "Alex", "Tim", "Francesco"]

developers.filter { $0 != "Tim" }