Mutating immutable obects: with= #8465
Replies: 3 comments
-
The proposed syntax looks awful in my opinion. Also I don't think this feature is worth the effort. |
Beta Was this translation helpful? Give feedback.
-
Very similar to #8114. |
Beta Was this translation helpful? Give feedback.
-
For me, the syntax isn't the issue, it's the idea that making it easy to replace an existing reference to a read-only thing with a reference to a new read-only thing is desirable. This feels like an attempt to work around the fact that record classes are read-only, rather than adding anything useful to the language.
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
public record Person(string FistName, string LastName);
Person person = new Person("John", "Doe");
//Changing last name...
person = person with { LastName = "Smith" };
//Proposal...
person with= { LastName = "Smith" };
Beta Was this translation helpful? Give feedback.
All reactions