作者回复: 我把你的例子改了一下,既然是赋值运算,你的实现里明显不是。 infix operator +-☀ : PlusMinusPrecedence precedencegroup PlusMinusPrecedence { associativity: none higherThan: AdditionPrecedence lowerThan: MultiplicationPrecedence assignment: true } struct Point { var x: Int, y: Int static func +-☀(left: inout Point, right: Point) { left = Point(x: left.x + right.x, y: left.y - right.y) } } struct Person { var point: Point } var person: Person? person?.point +-☀ Point(x: 10, y: 20) print(person?.point as Any) 你可以尝试把assignment的true改成false,是会报错的,所以assignment的可选链里的作用如下: “This proposal quietly drops the assignment modifier that exists on operators today. This modifier had one important function–an operator marked assignment gets folded into an optional chain, allowing foo?.bar += 2 to work as foo?(.bar += 2) instead of failing to type-check as (foo?.bar) += 2. In practice, all Swift operators currently marked assignment are at the equivalent of the Assignment precedence level, so the core team recommends making this optional chaining interaction a special feature of the Assignment precedence group.”
作者回复: assignment只是表明是否是赋值,你这个有代码么,拿出来看一下