Created
June 15, 2017 00:10
-
-
Save Qata/9687cdbaf611cfa5fd4c3456af5c7e3e to your computer and use it in GitHub Desktop.
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 Sequence { | |
func map<U>(_ keyPath: KeyPath<Element, U>) -> [U] { | |
return map { $0[keyPath: keyPath] } | |
} | |
func flatMap<U>(_ keyPath: KeyPath<Element, U?>) -> [U] { | |
return flatMap { $0[keyPath: keyPath] } | |
} | |
func flatMap<U, S: Sequence>(_ keyPath: KeyPath<Element, S>) -> [U] where S.Iterator.Element == U { | |
return flatMap { $0[keyPath: keyPath] } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment