Skip to content

Instantly share code, notes, and snippets.

@reddavis
Created February 5, 2019 08:06
Show Gist options
  • Save reddavis/3e61147b62002c35bb9c4d6910e94c3c to your computer and use it in GitHub Desktop.
Save reddavis/3e61147b62002c35bb9c4d6910e94c3c to your computer and use it in GitHub Desktop.
internal extension KeyedDecodingContainer
{
internal func decode<T: Decodable>(_ key: KeyedDecodingContainer<K>.Key) throws -> T
{
return try self.decode(T.self, forKey: key)
}
internal func decodeIfPresent<T: Decodable>(_ key: KeyedDecodingContainer<K>.Key) throws -> T?
{
return try self.decodeIfPresent(T.self, forKey: key)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment