Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Match expression's @ operator not mentioned in docs #2999

Open
sdasda7777 opened this issue Mar 25, 2024 · 1 comment
Open

Match expression's @ operator not mentioned in docs #2999

sdasda7777 opened this issue Mar 25, 2024 · 1 comment

Comments

@sdasda7777
Copy link

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()
@SethTisue
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants