Last active
February 27, 2017 03:42
-
-
Save mzumi/5daf87b758f1c10a849d67167b4f4c67 to your computer and use it in GitHub Desktop.
This file contains 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 : ExpressibleByStringLiteral { | |
func extractValue<T>(key: String) throws -> T { | |
let keyStr = key as! Key | |
if let r = self[keyStr] as? T { | |
return r | |
} | |
throw JSONDecodeError.missingValue(key: key, actualValue: self[keyStr]) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment