Index Initializers for Record 'with' expressions #8018
Unanswered
altworowsky
asked this question in
Language Ideas
Replies: 1 comment 5 replies
-
That could be a bit awkward. Record cloning is shallow, so any internal collection state would be shared between the two instances and you would end up mutating the first instance. |
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.
-
In C# 12, we're able to define our own object initializers with indexers or 'index initializers' for records.
But, we're not able to use those index initializers with a 'with' expression.
The latter feels like a natural interaction between the index initializer and 'with' expression syntaxes. I would suggest that the language be amended to allow for the use of indexer initializers with 'with' expressions.
Beta Was this translation helpful? Give feedback.
All reactions