Skip to content

Instantly share code, notes, and snippets.

@mwaterfall
Last active January 13, 2019 11:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mwaterfall/7090c1282cd7079e9da14720ee4df8a8 to your computer and use it in GitHub Desktop.
Save mwaterfall/7090c1282cd7079e9da14720ee4df8a8 to your computer and use it in GitHub Desktop.
extension Material {
init(from decoder: Decoder) throws {
let container = try decoder.singleValueContainer()
let rawMaterial = try container.decode(String.self)
self = Material(rawValue: rawMaterial) ?? .other
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment