[Proposal]: Better Initialization of Records with Immutable{Collection} Properties #4196
Unanswered
TonyValenti
asked this question in
Language Ideas
Replies: 1 comment 5 replies
-
How should the compiler recognise these collections? |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Better Initialization of Records with Immutable{Collection} Properties
Summary
Simply the process of manipulating records which have Immutable{Collection} Properties
Motivation
Records and immutable collections conceptually pair nicely together, however, the immutable collections don't work nicely with records.
Detailed design
Suppose I have a record like this:
It would be nice to be able to say:
or similarly:
However, the compiler doesn't realize that adding items to an immutable collection returns the new collection so you end up having to do something like this:
I propose that immutable collections be recognized by the compiler and their new collection should be used.
Drawbacks
None that I can think of.
Alternatives
This doesn't have to be done but sure would be nice!
Unresolved questions
N/A
Design meetings
N/A
Beta Was this translation helpful? Give feedback.
All reactions