say i have a very simple Person
class
class Person {
var name:String
init(name:String) {
self.name = name
}
}
and i wish to store a collections of such Person
s in a property, which is an array with type Person, of a People class
class People {
var list:[Person] = []
}
perhaps i achieve this as follows
var alex = Person(name:"Alex")
var people = People()
people.list.append(alex)
QUESTION: how do i check if people.list contains the instance alex, please?
my simple attempt, which i was hoping to return true
people.list.contains(alex)
calls an error "cannot convert value of type 'Person' to expected argument type '@noescape (Person) throws -> Bool'"
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…