Skip to content

Instantly share code, notes, and snippets.

@jayrhynas
Created May 22, 2018 16:30
Show Gist options
  • Save jayrhynas/8ab522c0f8885be9500ae5d9908b919f to your computer and use it in GitHub Desktop.
Save jayrhynas/8ab522c0f8885be9500ae5d9908b919f to your computer and use it in GitHub Desktop.
extension Array {
func map<K, R>(keyPath kp: K) -> [R] where K: KeyPath<Element, R> {
return self.map { $0[keyPath: kp] }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment