Then, returning index seems the most consistent.
table.remove takes index and returns value, so table.insert can take value and
return index.
----- Original Message -----
Sent: Monday, December 21, 2009 4:52
AM
Subject: Re: about table.insert return
value (==nil)
On Sun, Dec 20, 2009 at 10:05 AM, Ico <lua@zevv.nl> wrote: > I guess the other
'logical' behaviour would be to return the newly > inserted element
instead of the table: > > thing = table.insert(sometable,
new_thing()) > > Maybe neither is implemented because they're both
equaly logical ?
I'd say that returning the item being inserted is at
least consistent with table.remove, which returns the removed
item.
Of course, one can always write a wrapper around table.insert
to return anything desired.
|