Skip to content

Instantly share code, notes, and snippets.

@MarioIannotta
Last active September 23, 2017 09:25
Show Gist options
  • Save MarioIannotta/f99adec9abd1aeb934b289d715ac2644 to your computer and use it in GitHub Desktop.
Save MarioIannotta/f99adec9abd1aeb934b289d715ac2644 to your computer and use it in GitHub Desktop.
Simple KeyedDecodingContainer subscript extension
extension KeyedDecodingContainer {
subscript<T: Decodable>(key: KeyedDecodingContainer.Key) -> T? {
return try? decode(T.self, forKey: key)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment