[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: about table.insert return value (==nil)
- From: Ico <lua@...>
- Date: Sun, 20 Dec 2009 16:05:03 +0100
* On 2009-12-20 frank <frank@frankhirsch.net> wrote :
>
> Hi, all!
>
> I find that table.insert returns nil instead of giving back the table.
>
> While I am not usually given to complaining about "missing features" and
> the all-to-common "why did you not do it the way _I_ want it" whining,
> in this case I must say I am quite perplexed by Lua's behaviour.
>
> Giving back the table as return value from table.insert would:
> - enable "sometable=table.insert(sometable or {},newelement)"
> - not break existing code
> - probably not significantly impact performance
>
> So, why not?
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 ?
--
:wq
^X^Cy^K^X^C^C^C^C