
27 Jun
2020
27 Jun
'20
1:09 a.m.
On 27/06/20 4:25 pm, Steven D'Aprano wrote:
Seriously, I genuinely thought that the existing behaviour was the opposite and that `add` unconditionally added the element. "Last seen wins".
The fact that you haven't noticed until now suggests that you've never written any code that depends on the difference.
If I was designing sets, that's probably how I would design it. After all, it's called *add*, not *add if not already there*.
But equally, if it's already there, there's no need to do anything, right?
I don't think it's possible to intuit the behaviour from the name "add".
I also think that it doesn't matter, and if it does, then a set probably isn't the right data structure for your application.
--
Greg