Skip to content

Instantly share code, notes, and snippets.

@fortmarek
Created September 9, 2020 15:00
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 fortmarek/2be414f06c4d032769fb5f4265ed3cff to your computer and use it in GitHub Desktop.
Save fortmarek/2be414f06c4d032769fb5f4265ed3cff to your computer and use it in GitHub Desktop.
enum CodingKeys: CodingKey {
case template
case dynamic(String)
init?(stringValue: String) {
switch stringValue {
case "template":
self = .template
case stringValue where Scaffold.attributes.contains(stringValue):
self = .dynamic(stringValue)
default:
return nil
}
}
var stringValue: String {
switch self {
case .template:
return "template"
case let .dynamic(name):
return name
}
}
// Not used
var intValue: Int? { nil }
init?(intValue _: Int) { nil }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment