Last active
February 1, 2018 13:43
-
-
Save loromits/f2390028c54f1d7a06ec25003e61b0a4 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 toDictionary<T: Hashable>(_ keyTransformer: (Element) throws -> T) rethrows -> Dictionary<T, Element> { | |
return try reduce(into: [:]) { try $0[keyTransformer($1)] = $1 } | |
} | |
} |
Author
loromits
commented
Feb 1, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment