Created
February 27, 2017 03:32
-
-
Save mzumi/39d252a668fff497c9795ad532f31e41 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 | |
} else { | |
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