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
Allow pattern matching in function arguments #813
Comments
Imported From: https://issues.scala-lang.org/browse/SI-813?orig=1 |
@dragos said: |
@odersky said: |
@SethTisue said: def bar: Foo => Int = { case Foo(x, y) => x + y } |
@adriaanm said: |
Luigi Plinge (rbj2001) said: def bar(foo: Foo) = { import foo._; x + y } Probably more efficient than going the unapply/extractor route since it's just a compile time thing. |
someone have links handy to discussions about this in the context of Dotty / Scala 3? |
it would be nice if we could define function arguments with pattern matching.
e.g.
Currently we have to either do:
Or
The latter is acceptable but tedious. The former becomes a right pain pretty quickly. It would be nice to be able to circumvent this problem altogether - particularly in the case of tuples.
The text was updated successfully, but these errors were encountered: