It’s worth pointing out that in!
gives the opposite status of what you want: in!
is true if the element already existed in the set and no change occurred, while push_and_get_status!
is true if the element is new and changed the set (well, your initial post’s version always changed the set, but you said that was not ideal so NonDairyNeutrino made it conditional). Therefore, you want the function composition !in!
.
Search the name on the page and it’s there among a lot of other set operations Base.in!. Of course the name would be far easier to discover if there were more links from suggestions in other docstrings, especially from in, push!, Set
. I evidently didn’t find it on the page either, mostly because I wrongly expected anything like it to also be implemented for dictionaries; in actuality, in!
was only implemented for sets precisely because of the extra factor of a paired value.
I also checked the implementation, the Set
method uses internals to avoid redundancy, the fallback AbstractSet
method has the redundancy and looks pretty much like NonDairyNeutrino’s method but with true
/false
swapped.