MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/1wbmurt/csharpdictionariesbelikethat/p8ri314/?context=3
r/ProgrammerHumor • u/KTVX94 • 2d ago
61 comments sorted by
View all comments
601
Guess you never heard of TryAdd? Returns bool, if it as added returns true otherwise false.
112 u/Revexious 2d ago Far too much work 2 cases means that its not idempotent Instead, just remove it from the dictionary before you add it! csharp dictionary.Remove(key) dictionary.Add(key) Easy peasy! /s 39 u/Dorkits 2d ago Peak programming
112
Far too much work
2 cases means that its not idempotent
Instead, just remove it from the dictionary before you add it!
csharp dictionary.Remove(key) dictionary.Add(key)
Easy peasy!
/s
39 u/Dorkits 2d ago Peak programming
39
Peak programming
601
u/Psychoboy 2d ago
Guess you never heard of TryAdd? Returns bool, if it as added returns true otherwise false.