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
given
3.1.1-RC1
Given:
class Foo: def bar = ()
This compiles:
Option(new Foo).map { implicit foo: Foo => summon[Foo].bar }
So does this:
for { given Foo <- Option(new Foo) } yield summon[Foo].bar
But, none of these do. Am I writing it wrong, or is it just not possible?
Option(new Foo).map { given Foo => // abstract givens cannot be annonymous summon[Foo].bar }
Option(new Foo).map { (given Foo) => // illegal start of simple expression summon[Foo].bar }
Option(new Foo).map { (given foo: Foo) => // illegal start of simple expression summon[Foo].bar }
Option(new Foo).map { given foo: Foo => // ; expected but => found summon[Foo].bar }
The text was updated successfully, but these errors were encountered:
Option(C()).map { ((x: C) ?=> summon[C])(using _) }
Sorry, something went wrong.
Option(C()).map { case given C => summon[C] }
As mentioned under "pattern-bound givens", same as for given.
for given
https://docs.scala-lang.org/scala3/reference/contextual/givens.html
Aha! That's a reasonable syntax, thanks :)
I'd still love to see something similar to Scala 2, if possible, so we can skip the case keyword.
case
implicit
-source:3.0-migration
No branches or pull requests
Compiler version
3.1.1-RC1
Minimized code
Given:
This compiles:
So does this:
But, none of these do. Am I writing it wrong, or is it just not possible?
The text was updated successfully, but these errors were encountered: