Created
December 27, 2015 16:29
-
-
Save raxcat/0fac15d56d04765933ac to your computer and use it in GitHub Desktop.
searchKeyOfValue swift dictionary extension
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 Dictionary where Key:Hashable, Value:Equatable { | |
func searchKeyOfValue(target:Value) -> Key? { | |
for (key, element) in self { | |
if element == target { | |
return key | |
} | |
} | |
return nil | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment