该功能仅适用于参数属性

时间:2019-10-31 11:26:36

标签: ios swift syntax properties where-clause

仅当参数的属性满足特定条件时,才有可能提供功能吗?例如,通过使用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
        }

    }
}

0 个答案:

没有答案
相关问题