swift - XCode 7 Beta 3 - Array extension -


old version of code before xcode 7 beta 3:

extension array {     func filterbyindex<s: sequencetype s.generator.element == int>(indices: s) -> [t] {         return array(permutationgenerator(elements: self, indices: indices))     }      func find(includedelement: t -> bool) -> int? {         (idx, element) in self.enumerate() {             if includedelement(element) {                 return idx             }         }         return nil     }  } 

new version of code after xcode 7 beta 3:

extension array {     func filterbyindex<s: sequencetype s.generator.element == int>(indices: s) -> [element] {         return array(permutationgenerator(elements: self, indices: indices))     }      func find(includedelement: element -> bool) -> int? {         (idx, element) in self.enumerate() {             if includedelement(element) {                 return idx             }         }         return nil     } } 

but function filterbyindex gives me error when write line:

let names = (namesarr as! [string]).filterbyindex(dupes) 

'[string]' not have member named 'filterbyindex'

what changed ?

the new version of code works fine me with:

[ "zero", "one", "two", "three", "four" ].filterbyindex([1, 3]) // result: [ "one", "three" ] 

i'm assuming problem you're having somewhere else. suspected type of dupes (the definition of not show) no matching requirements of generic function, in tests error message should different in case.


Comments