我收到以下错误:Binary operator '===' cannot be applied to type of 'Self.Element' and 'AnyObject' on the line: return contains { $0 === object }
。
有没有办法转换object
为 的类型Iterator.Element
?这条线是否where Iterator.Element: AnyObject
意味着Iterator.Element
必须可以表示为AnyObject
?
extension Sequence where Iterator.Element: AnyObject {
/**
- Parameter object:
*/
func containsObjectIdentical(to object: AnyObject) -> Bool {
return contains { $0 === object }
}
}
感谢您对此事的任何帮助。