Last active
August 9, 2017 07:32
-
-
Save efremidze/5515433fb474917d2e5f122d41852e84 to your computer and use it in GitHub Desktop.
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 Value == Any { | |
func value<T>(forKey key: Key, defaultValue: @autoclosure () -> T) -> T { | |
guard let value = self[key] as? T else { return defaultValue() } | |
return value | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment