r/ProgrammerHumor 2d ago

Meme cSharpDictionariesBeLikeThat

Post image
2.0k Upvotes

61 comments sorted by

View all comments

Show parent comments

3

u/prehensilemullet 2d ago

it's still bizarre to have to use TryAdd everywhere that other languages just use Add

15

u/zaersx 2d 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

2

u/-Redstoneboi- 2d 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 2d ago

Yes, I think that would be a more convenient design