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, {})

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
P#62932 2019-03-21 12:37

I concur.

P#62951 2019-03-22 10:33

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

Changed: del() returns the item deleted on success
P#63424 2019-04-12 05:55


P#63451 2019-04-12 14:42

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2023-03-22 15:58:47 | 0.004s | Q:11