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
Swift 4/5
Another way to achieve this is with the filter function
var elements = [1,2,3,4,5] if let object = elements.filter({ $0 == 5 }).first { print("found") } else { print("not found") }