docs.scala-lang icon indicating copy to clipboard operation
docs.scala-lang copied to clipboard

Match expression's `@` operator not mentioned in docs

Open sdasda7777 opened this issue 1 year ago • 1 comments

I would understand it not being included in the docs if this was experimental feature, but it seems to work in both Scala 2 and Scala 3. Specifically I mean this extremely helpful @ operator which allows you to both unapply the object for matching and upcast it for use in the code branch:

case a @ A(x) => a.classASpecificStuff()
case b @ B(x) if x > 0 => b.classBSpecificStuff()

sdasda7777 avatar Mar 25 '24 12:03 sdasda7777

It's not experimental, and I agree it's a strange omission.

I think https://docs.scala-lang.org/tour/pattern-matching.htm should cover it too.

SethTisue avatar May 21 '24 15:05 SethTisue