Skip to content

Instantly share code, notes, and snippets.

@mwaterfall
Last active January 13, 2019 11:19
Show Gist options
  • 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