【发布时间】:2016-11-16 15:00:35
【问题描述】:
我想为数组编写一个扩展来检查一个数组是否包含另一个数组的所有元素,在我的用例中它是字符串对象,但我一直得到:
Cannot convert value of type 'T.Generator.Element' to expected argument type '@noescape _ throws -> Bool'
在self.contains(item)这一行中关于item的错误
这是我的代码:
extension Array {
func containsArray<T : SequenceType where T.Generator.Element : Equatable> (array:T) -> Bool{
for item:T.Generator.Element in array{
if !self.contains(item) {
return false
}
}
return true
}
}
【问题讨论】:
标签: ios arrays swift generics swift2