The interface for the find function is / was:
func find<C : CollectionType where C.Generator.Element : Equatable>(domain: C, value: C.Generator.Element) -> C.Index?
This suggests that CollectionType of C should contain Equatable elements and, in addition, value should also be Equatable .
[ Swift 3.0 Note : With Swift 3.0 you will need to use the index function, which comes in two flavors. First, you provide your own predicate:
func index(where: (Self.Generator.Element) -> Bool) -> Self.Index?
In the second case, your elements should be equivalent:
If you decide to switch to the Equatable route, the following applies. Note> ]
The structure of the Score not Equatable and therefore an error. You need to figure out what it means that the points must be equal to each other. Perhaps this is a somewhat numerical estimate; perhaps this is a "rating" and "user ID". It depends on your abstraction. Score . Once you know, you implement == using:
func == (lhs:Score, rhs:Score) -> Bool { return // condition for what it means to be equal }
Note: if you use class and therefore points have an "identifier", you can implement this as:
func == (lhs:Score, rhs:Score) -> Bool { return lhs === rhs }
Your string example works because String is Equatable . If you look in the code of the Swift library, you will see:
extension String : Equatable {} func ==(lhs: String, rhs: String) -> Bool