Skip to content

Instantly share code, notes, and snippets.

@hyperspacemark
Created August 21, 2015 21:32
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 hyperspacemark/5d9bd429959f3f98b596 to your computer and use it in GitHub Desktop.
Save hyperspacemark/5d9bd429959f3f98b596 to your computer and use it in GitHub Desktop.
A new implementation of `flatMap(f:)` added to `SequenceType` in Swift 2.0.
extension SequenceType {
/// Return an `Array` containing the non-nil results of mapping
/// `transform` over `self`.
///
/// - Complexity: O(*M* + *N*), where *M* is the length of `self`
/// and *N* is the length of the result.
public func flatMap<T>(@noescape transform: (Self.Generator.Element) -> T?) -> [T]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment