-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Feature Request: Add AddOrUpdate
to the Dictionary API
#1221
Comments
Isn't it what the indexer does? |
Maybe, do you have a link reference? |
Ah yes, I suppose what I'm advocating is to avoid having to use that syntax. Instead the simple update would look something like this:
Note: that I'm using it as an extension method at present. I'll hold on the PR for now. |
I second the request for |
Related discussion: https://github.com/dotnet/corefx/issues/31126 |
To match the shape of |
Related to #36942 |
There is a
Add(TKey key, TValue value)
method but it throws if using a key that is already in use.Adding
AddOrUpdate(TKey key, TValue value)
will simply use an existing key or add it.Simply to be more clear and avoid boilerplate code and possibly an unnecessary lookup.
PR coming soon as it's fairly trivial.
The text was updated successfully, but these errors were encountered: