You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jun 5, 2023. It is now read-only.
When matching, you have to choose to use a pattern binder with the @ notation or to destruct.
A lot of expressivity could be gained by allowing both, especially with #127
Current
Foo(1, Bar(true), K) match {
caseFoo(1, b, k) if manual_check(b, k) => println(s"p is ${b.p}, k is $k")
// ORcase f @FooCheck() if f.x ==1=> println(s"p is ${f.bar_field.p}, k is ${f.k}")
...
}
Proposed
Foo(1, Bar(true)) match {
caseFoo(1, Bar(p), k) @Guard() => println(s"p is $p, k is $k")
...
}
The text was updated successfully, but these errors were encountered:
The x @ p syntax is the "pattern binder" (cf. the specification ), whereas the "guard" is the if condition.
You can already do
case f @Foo(1, b, k) => ...
With your own unapply function it seems to me that you could apply checks and extract values all at once. Is there a situation where this doesn't give enough flexibility?
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Description
When matching, you have to choose to use a pattern binder with the
@
notation or to destruct.A lot of expressivity could be gained by allowing both, especially with #127
Current
Proposed
The text was updated successfully, but these errors were encountered: