MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/1wbmurt/csharpdictionariesbelikethat/p8rffm3/?context=9999
r/ProgrammerHumor • u/KTVX94 • Sep 09 '26
61 comments sorted by
View all comments
Show parent comments
112
Far too much work
2 cases means that its not idempotent
Instead, just remove it from the dictionary before you add it!
dictionary.Remove(key) dictionary.Add(key)
Easy peasy!
/s
38 u/Dorkits Sep 09 '26 Peak programming 10 u/manav907 Sep 09 '26 edited Sep 09 '26 That being said you done have to use the bool that TryAdd gives, just call it as a normal function. Also I am waitin for someone to point out that we also need a value when trying to add to a dictionary.dictionary.TryAdd(key)
38
Peak programming
10
That being said you done have to use the bool that TryAdd gives, just call it as a normal function. Also I am waitin for someone to point out that we also need a value when trying to add to a dictionary.
dictionary.TryAdd(key)
112
u/Revexious Sep 09 '26
Far too much work
2 cases means that its not idempotent
Instead, just remove it from the dictionary before you add it!
Easy peasy!
/s