【发布时间】:2016-05-28 08:47:59
【问题描述】:
为什么这不起作用?我可以在字符串上使用 array.contains() 但它不适用于对象。
var array = ["A", "B", "C"]
array.contains("A") // True
class Dog {
var age = 1
}
var dogs = [Dog(), Dog(), Dog()]
var sparky = Dog()
dogs.contains(sparky) // Error Cannot convert value of type 'Dog' to expected argument type '@noescape (Dog) throws -> Bool
【问题讨论】: