lua-users home
lua-l archive

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


On 13 December 2010 12:41, steve donovan <steve.j.donovan@gmail.com> wrote:
> On Mon, Dec 13, 2010 at 7:36 PM, Javier Guerra Giraldez
> <javier@guerrag.com> wrote:
>> is there any undesired effect to table.insert(t,nil) when t is a
>> well-formed array?  after all, it's inserting nil at the end,  leaving
>> the table unchanged and therefore still holeless  :-)
>
> Sometimes we even rely on table.insert(t,nil) being a no-op.
>
> The problem is that a map is supposed to take an array of N elements
> and transform it into another array of N elements  (unless you allow
> it to 'filter' as well, which seems sneaky.)

I always differentiate between map and imap (analogous to pairs and
ipairs). map functions can return nil, but imap functions should not.

    henk