Skip to content

Instantly share code, notes, and snippets.

@robskillington
Created September 30, 2014 23:02
Show Gist options
  • Save robskillington/702a02e4e59091d5ace8 to your computer and use it in GitHub Desktop.
Save robskillington/702a02e4e59091d5ace8 to your computer and use it in GitHub Desktop.
valueForKey for simple value or nil operation
extension Dictionary {
func valueForKey<T>(key: Key) -> T? {
if let value = self[key] as? T {
return value
} else {
return nil
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment