仅当参数的属性满足特定条件时,才有可能提供功能吗?例如,通过使用where关键字?我在下面举了一个例子。
struct ASN1 {
enum Types: UInt8 {
case constructed
case primitive
}
class Tag {
let type: Types
}
class Encoder {
func enter(tag: ASN1.Tag) where tag.type == .constructed {
// Function only available when tag property type is .constructed
}
}
}