示例工程 18-value-semantics-cow

18-value-semantics-cow/Diagnostics/MutatingGetterOnLet.swift

swift · 0.2 KB

// 故意编译失败:mutating getter 不能在 let 实例上调用。
// 复现:swiftc Diagnostics/MutatingGetterOnLet.swift
struct Probe {
    var unique: Bool {
        mutating get { true }
    }
}
 
let probe = Probe()
print(probe.unique)