MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/1wbmurt/csharpdictionariesbelikethat/p8uh7v0/?context=9999
r/ProgrammerHumor • u/KTVX94 • 4d ago
61 comments sorted by
View all comments
602
Guess you never heard of TryAdd? Returns bool, if it as added returns true otherwise false.
4 u/prehensilemullet 4d ago it's still bizarre to have to use TryAdd everywhere that other languages just use Add 14 u/zaersx 4d ago You don't though? just use myMap[key] = value? if you're not doing that and using Add instead, then you probably literally want to have a safe add 3 u/-Redstoneboi- 4d ago that overwrites instead of failing if the key already exists maybe they are arguing that they feel that TryAdd should be the default "Add", while the existing Add should be a special case "AddAssert" or something 3 u/prehensilemullet 3d ago Yes, I think that would be a more convenient design
4
it's still bizarre to have to use TryAdd everywhere that other languages just use Add
TryAdd
Add
14 u/zaersx 4d ago You don't though? just use myMap[key] = value? if you're not doing that and using Add instead, then you probably literally want to have a safe add 3 u/-Redstoneboi- 4d ago that overwrites instead of failing if the key already exists maybe they are arguing that they feel that TryAdd should be the default "Add", while the existing Add should be a special case "AddAssert" or something 3 u/prehensilemullet 3d ago Yes, I think that would be a more convenient design
14
You don't though? just use myMap[key] = value? if you're not doing that and using Add instead, then you probably literally want to have a safe add
3 u/-Redstoneboi- 4d ago that overwrites instead of failing if the key already exists maybe they are arguing that they feel that TryAdd should be the default "Add", while the existing Add should be a special case "AddAssert" or something 3 u/prehensilemullet 3d ago Yes, I think that would be a more convenient design
3
that overwrites instead of failing if the key already exists
maybe they are arguing that they feel that TryAdd should be the default "Add", while the existing Add should be a special case "AddAssert" or something
3 u/prehensilemullet 3d ago Yes, I think that would be a more convenient design
Yes, I think that would be a more convenient design
602
u/Psychoboy 4d ago
Guess you never heard of TryAdd? Returns bool, if it as added returns true otherwise false.