Check if array contains element


I want to check if an array contains a specific value/element.


// Initialize the Array
var a = [1,2,3,4,5]

// Check if it contains the number '6'

if a.contains(6) {
    print("Yes, it does contain number 6")
else {
    print("No, it doesn't")

Heard the news?

The Swift Cookbook for Swift 3 is at last here! For iBooks, Kindle and Paperback.
Hurry up - and Check it out! ;-)