0

I tried this:

var array = ["led","zepp","jimmy","page"]

if array.contains("jimmy") { // error : [String] does not have a member named 'contains' .
    print("yes")
}

What is the syntax for the [String] type array?

1
  • 1
    Your syntax is correct for Swift 2. For Swift 1.2, if contains(array, "jimmy") Commented Aug 15, 2015 at 12:00

1 Answer 1

0

depends on version of swift... in 1.2:

    var array = ["led","zepp","jimmy","page"]
    if find(array, "jimmy") != nil {
        println("yay")
    }

in swift 2

   var array = ["led","zepp","jimmy","page"]
    if array.indexOf("jimmy") != nil {
        print("yay")
    }
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.