Skip to content

Instantly share code, notes, and snippets.

@jayrhynas
Last active May 22, 2018 16:50
Show Gist options
  • Save jayrhynas/8c253efa5499b7040e3d47df9f87ad49 to your computer and use it in GitHub Desktop.
Save jayrhynas/8c253efa5499b7040e3d47df9f87ad49 to your computer and use it in GitHub Desktop.
extension Dictionary {
init<S>(grouping values: S, by kp: KeyPath<S.Element, Key>) throws where Value == [S.Element], S: Sequence {
try self.init(grouping: values, by: { $0[keyPath: kp] })
}
}
// Crashes:
// extension Dictionary {
// init<S, K>(grouping values: S, by kp: K) throws where Value == [S.Element], S: Sequence, K: KeyPath<S.Element, Key> {
// try self.init(grouping: values, by: { $0[keyPath: kp] })
// }
// }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment