We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Originally reported by @TheDying0fLight -- I thought there already was an issue for this, but I couldn't find it, sorry!
The following nested pattern matching of a tuple in lambda case is not supported:
[(1, 2), (3, 4)].foldLeft(0) { (acc, (x, y)) => acc + x + y }
as it returns a parser error Expected ; on the => token.
Expected ;
=>
What also doesn't work is using case like Scala would (see comment below):
case
[(1, 2), (3, 4)].foldLeft(0) { case (acc, (x, y)) => acc + x + y }
as that reports Wrong number of value arguments, given 1, but function expects 2.
Wrong number of value arguments, given 1, but function expects 2.
A workaround that does actually work is, for example:
[(1, 2), (3, 4)].foldLeft(0) { (acc, tup) => val (x, y) = tup; acc + x + y }
(or just using tup.first, tup.second)
tup.first
tup.second
This doesn't show up only for tuples, but for anything nested in general:
record Person(name: String, age: Int) def main() = [Person("Joe", 42), Person("Jolene", 24)].foldLeft(0) { (acc, Person(name, age)) => acc + age }
again returns Expected ; on the =>.
This is somewhat related to #707.
The text was updated successfully, but these errors were encountered:
I think that in Scala 3, one needs the case keyword here:
List((1, 2), (3, 4)).foldLeft(0) { case (acc, (x, y)) => acc + y }
Sorry, something went wrong.
What about the Coq / Roq style?
foo { case x, y => ... }
which "clearly" matches on two arguments, not a tuple.
No branches or pull requests
Originally reported by @TheDying0fLight -- I thought there already was an issue for this, but I couldn't find it, sorry!
The following nested pattern matching of a tuple in lambda case is not supported:
as it returns a parser error
Expected ;
on the=>
token.What also doesn't work is using
case
like Scala would (see comment below):as that reports
Wrong number of value arguments, given 1, but function expects 2.
A workaround that does actually work is, for example:
(or just using
tup.first
,tup.second
)This doesn't show up only for tuples, but for anything nested in general:
again returns
Expected ;
on the=>
.This is somewhat related to #707.
The text was updated successfully, but these errors were encountered: