Reputation: 3952
I'm following a tutorial and I noticed the author(s) declared this enum with what looks like to be multiple types. Based on what I've read online from the Swift Standard Library, I understand enums can be of a certain type and enums do not support inheritance. Is this enum of both String and CodingKey type? Or is the name case a String type and the items case a CodingKey type?
private enum CodingKeys: String, CodingKey {
case name
case items
}
Upvotes: 0
Views: 251
Reputation: 63167
This isn't inheritance, it's two things:
enum
's cases. In this case, it's String
. When an enum has chosen to have a String raw value, but the case doesn't specify a raw value, the name of the case is implicitly assumed to be the raw value of the case.CodingKey
.Upvotes: 3