Skip to content

Instantly share code, notes, and snippets.

@doozMen
Created June 11, 2015 18:13
Show Gist options
  • Save doozMen/4a7cdc7996c03cf6f460 to your computer and use it in GitHub Desktop.
Save doozMen/4a7cdc7996c03cf6f460 to your computer and use it in GitHub Desktop.
Array index extension
extension Array {
func indexes<T>(xs: [T], check: T -> Bool) -> [Int] {
var result = [Int]()
var i = 0
for x in xs {
if check(x) {
result.append(i)
}
i++
}
return result
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment