lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]



* 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