In Swift, how can I check if an element exists in an array? Xcode does not have any suggestions for contain, include, or has, and a qu
contain
include
has
let elements = [1, 2, 3, 4, 5, 5]
elements.contains(5) // true
elements.firstIndex(of: 5) // 4 elements.firstIndex(of: 10) // nil
let results = elements.filter { element in element == 5 } results.count // 2