Skip to content

Instantly share code, notes, and snippets.

@raxcat
Created December 27, 2015 16:29
Show Gist options
  • Save raxcat/0fac15d56d04765933ac to your computer and use it in GitHub Desktop.
Save raxcat/0fac15d56d04765933ac to your computer and use it in GitHub Desktop.
searchKeyOfValue swift dictionary extension
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