Carpet

Carpet

2M Downloads

we need `pop(container, address, new_value)`

rv3r opened this issue ยท 5 comments

commented

From scarpet docs for delete()

For lists and maps returns previous entry at the address, for nbt's - number of removed objects, with 0 indicating that the original value was unaffected.

but also

Returns true, if container was changed, false, if it was left unchanged, and null if operation was invalid.

Currently, it appears as though the second is implemented. Which is the intended behavior and which should be removed from the docs?

commented

It would be nie if the first behaviour was the implemented one, since we don't have an alternative pop function. That makes hard to differentiate between failed deletes and null values in the container, though.

commented

for that you could use 'has' method. Indeed the docs are misleading - the first behaviour is more practical

commented

its actually a fairly recent change that was 'just' supposed to be a refactor and slipped through the review
9d9844f

commented

Correction - previous behaviour was the same - the current implementation only return a boolean. I would also prefer it would act like a pop

commented

7a3ad7f technically fixes it, but will keep this open and rename as a pop() suggestion