XCode 7 Beta 3 之前的旧版本代码:
extension Array {
func filterByIndex<S: SequenceType where S.Generator.Element == Int>(indices: S) -> [T] {
return Array(PermutationGenerator(elements: self, indices: indices))
}
func find(includedElement: T -> Bool) -> Int? {
for (idx, element) in self.enumerate() {
if includedElement(element) {
return idx
}
}
return nil
}
}
XCode 7 Beta 3 之后的新版本代码:
extension Array {
func filterByIndex<S: SequenceType where S.Generator.Element == Int>(indices: S) -> [Element] {
return Array(PermutationGenerator(elements: self, indices: indices))
}
func find(includedElement: Element -> Bool) -> Int? {
for (idx, element) in self.enumerate() {
if includedElement(element) {
return idx
}
}
return nil
}
}
但是现在当我写这行时,函数 filterByIndex 给了我一个错误:
let names = (namesArr as! [String]).filterByIndex(dupes)
“[String]”没有名为“filterByIndex”的成员
有什么改变?