Created
April 17, 2016 16:47
-
-
Save samirGuerdah/aa4f27761503e4ec65b7560813569101 to your computer and use it in GitHub Desktop.
Sample flatMap function as extension in Array
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension Array { | |
func sg_flatMap<U>(transform: (Generator.Element) -> [U]) -> [U] { | |
var result = [U]() | |
for item in self { | |
result.appendContentsOf(transform(item)) | |
} | |
return result | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment