Log In  


This isn't exactly a bug, but an aspect of the API that bothers me a bit.

In PICO-8:

add(table, element) -- returns the added element
del(table, element) -- returns nil

This doesn't make much sense to me. Returning the added element is a nice convenience, since it allows you to do things like creating multidimensional tables succintly:

for x=1, width do
 local col = add(table, {})
 for y=1, height do
  add(col, {})
 end
end

But returning nil when deleting an element does not make sense to me. If it returned the deleted element, it would be possible to know whether an element was found or not, without first checking for membership.

For comparison, this is how it is in Lua:

table.insert(table, element) -- returns nil
table.remove(table, position) -- returns the removed element
1


I concur.


2

I didn't anticipate it, but this is in fact fixed in 0.1.12!

Changed: del() returns the item deleted on success

nice!



[Please log in to post a comment]