For example, imagine an HTTP server's request handler is typed `Request ?=> Response`, so the request object is "given" within its body at the callsite. Defining, def request(using Request) = summon[Request] in the library means the request will always have the name `request`.
-
-
Show this thread
-
Compare that to a "normal" (non-context) function parameter, where one user will write `{ r => ... }`, another will write `{ req => ... }` and another will write `{ httpRequest => ... }`. Any user reading that code needs to learn the parameter name for each use site.
Show this thread
End of conversation
New conversation -
-
-
Just found a good use case for context function at work, but I will have to do it with scala 2 syntax for a bit before pushing the team to upgrade to scala 3.
-
Luckily you still have the { implicit foo => ... } syntax in Scala 2, so in theory, that part of your upgrade should be just a matter of removing the lambda variable.
- Show replies
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.