Created
August 19, 2019 10:23
-
-
Save vakhidbetrakhmadov/20985790b3759ee017d1e8c64b55abae to your computer and use it in GitHub Desktop.
This file contains 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 grouped<T: Hashable>(by keyPath: KeyPath<Element, T>) -> [T: [Element]] { | |
return .init(grouping: self, by: { $0[keyPath: keyPath] }) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment