ID:1863987
 
Applies to:DM Language
Status: Open

Issue hasn't been assigned a status value.
The byond proc Remove serves the function of internally taking an element out of a list if possible and returning 1 or 0 if an object was actually removed. In every other way it is identical to the byond operator -=.

The byond operator |= can potentially add something to a list, or not add something to the list depending on whether the list already contains all/some/none of the elements.

It would be nice if, just as Remove can be used to tell your code if something was actually removed by -=, there was some kind of proc equivalent to that for the |= operator to tell if something was actually added to the list. It would either return 1 if any element was added, or 0 if no elements were added.
Agreed, it would be pretty helpful. In the meantime you can kind of hack you way around it by comparing the value of list.len from before the operation to list.len after the operation, if it has changed you know there was a successful addition.

It's a bit more overhead and work that would be worthwhile though in most cases, so an addition like the one you're suggestion would definitely be nice.
proc
unique_add(list/list,value)
. = list.len
list |= value
. = list.len - .


Too bad we can't add procs to the /list pseudotype...