[Proposal]: Compound assignment in object initializer and `with` expression
- Dominant language
- C#
- Stars
- 12.7k
- Forks
- 1.1k
- Avg merge
- 11h 1m
- Merged PRs (30d)
- 3
Description
# Compound assignment in object initializer and `with` expression
- Specification: https://github.com/dotnet/csharplang/blob/main/proposals/compound-assignment-in-initializer-and-with.md
- Discussion: https://github.com/dotnet/csharplang/discussions/8650
## Summary
Allow compound assignments in an object initializer:
```cs
var timer = new DispatcherTimer
{
Interval = TimeSpan.FromSeconds(1d),
Tick += (_, _) => { /*actual work*/ },
};
```
Or a `with` expression:
```cs
var newCounter = counter with { Value -= 1 };
```
## Design meetings
https://github.com/dotnet/csharplang/blob/main/meetings/2021/LDM-2021-09-20.md#object-initializer-event-hookup
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.