[英]Is this enum of two different types?
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.
根据我从Swift标准库在线阅读的内容,我了解到枚举可以是某种类型,并且枚举不支持继承。 Is this enum of both String and CodingKey type?
这个枚举类型是否为String和CodingKey? Or is the name case a String type and the items case a CodingKey type?
还是名称大小写是String类型,项目大小写是CodingKey类型?
private enum CodingKeys: String, CodingKey {
case name
case items
}
This isn't inheritance, it's two things: 这不是继承,是两件事:
enum
's cases. enum
案例的“后备值”。 In this case, it's String
. 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
. CodingKey
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.