Skip to content

Add experimental NamedTuple copyFrom method #23135

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

bishabosha
Copy link
Member

copyFrom chosen as it has a slight difference i.e. the argument should be surrounded in extra parentheses. Also, it can not be used for target typing of fields.

`copyFrom` chosen as it has a slight difference i.e. the argument should be surrounded in extra parentheses.
Also, it can not be used for target typing of fields.
@bishabosha
Copy link
Member Author

rebased


@main def Test =
val foo: Foo = (name = "foo", mod = "some_mod")
val foo_updated: Foo = foo.copyFrom((mod = "bar")) // error, stays as String
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here is a demo of the limitation of no target typing, which I guess could be mitigated with a dedicated feature, or a secondary library solution based on lenses

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant