Created
September 30, 2014 23:02
-
-
Save robskillington/702a02e4e59091d5ace8 to your computer and use it in GitHub Desktop.
valueForKey for simple value or nil operation
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 { | |
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