示例工程 06-functions-closures

06-functions-closures/Diagnostics/OverlappingInout.swift

swift · 0.3 KB

// 故意编译失败:同一个变量不能同时以 inout 传入两次。
// 复现:swiftc Diagnostics/OverlappingInout.swift
func addBoth(_ lhs: inout Int, _ rhs: inout Int) {
    lhs += 1
    rhs += 1
}
 
var value = 0
addBoth(&value, &value)
print(value)