Skip to content

Conversation

tgodzik
Copy link

@tgodzik tgodzik commented Aug 28, 2025

Backports scala#23775 to the 3.3.7.

PR submitted by the release tooling.
[skip ci]

Allow for postfix operators to be followed by assigns.
This enables the definition and use of the following syntax (more
precisely the parsing of the `>_=` method as a `postfix operator +
assign`):
```scala
val v = new Vector(1, 2, 3)
println(v) // prints <1, 2, 3>
v<1> = 10 // assign 10 to element at index 1
println(v) // prints <1, 10, 3>
println(v<1>) // prints: value at 1 is 10

// Definition of Vector:

class Vector(values: Int*) {
  val data = values.toArray
  class Getter(i: Int) {
    def `>_=`(x: Int) =
      data(i) = x
    def > : Int =
      data(i)
  }
  def < (i:Int) = new Getter(i)
  override def toString = data.mkString("<", ", ", ">")
}
```
[Cherry-picked de18af4]
Base automatically changed from backport-lts-3.3-23710 to lts-3.3 August 29, 2025 11:03
@tgodzik
Copy link
Author

tgodzik commented Aug 29, 2025

No regressions detected in the community build up to backport-lts-3.3-23805.

Reference

@tgodzik tgodzik merged commit d79c7b0 into lts-3.3 Aug 29, 2025
22 checks passed
@tgodzik tgodzik deleted the backport-lts-3.3-23775 branch August 29, 2025 11:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants