Skip to content

Instantly share code, notes, and snippets.

@Nub
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Nub/d5c999959eb7196c8687 to your computer and use it in GitHub Desktop.
Save Nub/d5c999959eb7196c8687 to your computer and use it in GitHub Desktop.
extension T[] {
func filterMap<U>(transform: (T) -> U?) -> U[] {
var newArray = U[]
for i in self {
if let filterMappedValue = transform?(i) {
newArray += filterMappedValue
}
}
return newArray
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment