How to remove all occurrences of a specific value from an array in Swift

1 Answer

0 votes
import Foundation

var arr = [3, 1, 2, 3, 4, 3, 5, 6, 3, 3]

// Remove all occurrences of a specific value
arr = arr.filter { $0 != 3 }

print(arr)



/*
run:

[1, 2, 4, 5, 6]

*/

 



answered Jan 22, 2025 by avibootz
...