我试过了:
var array = ["led","zepp","jimmy","page"]
if array.contains("jimmy") { // error : [String] does not have a member named 'contains' .
print("yes")
}
[String]
类型数组的语法是什么?
答案 0 :(得分:0)
取决于swift的版本......在1.2:
var array = ["led","zepp","jimmy","page"]
if find(array, "jimmy") != nil {
println("yay")
}
在swift 2中
var array = ["led","zepp","jimmy","page"]
if array.indexOf("jimmy") != nil {
print("yay")
}