Partial Override of Parameters: Using+Named Arguments #25024
Replies: 1 comment
-
|
Classes require a non-implicit param list, and it was an intentional change that it comes after a contextual param list as in the example. ( Off-the-cuff, I don't know why the last invocation is different, but maybe it just misses the adaptation. If Edit: oh maybe that's why: the second application infers the missing arg list; the third infers the missing args for the first param list, not the missing param list. I agree it would be nice to have a doc page, just to illustrate what happens. It's easier to read examples (qua cargo cult) than think through the rules (when there are rules). Showing the default arg: then |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I discovered a strange pattern in Scala 3 that appears to be undocumented: using named arguments within a using clause to override only some context parameters while letting others be resolved from scope.
I searched the documentation, GitHub issues, and forums but found no mention of this.
Key Observations:
✅ MyClass(using stringParam = "x")()
❌ MyClass()(using stringParam = "x") - does not compile
Questions
Beta Was this translation helpful? Give feedback.
All reactions