4 ms·
An annoyance I have is "add" does not return a boolean indicating if the set already contains the entry. Most runtimes do this to prevent the need for a double
by joe_guy 3y ago
An annoyance I have is "add" does not return a boolean indicating if the set already contains the entry.
Most runtimes do this to prevent the need for a double lookup cost by doing "has" then "add."
It's a common pattern for when the set is used to either know when to or when not to do expensive work.