lua-users home
lua-l archive

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

On Sat, Jan 8, 2011 at 11:54 PM, Henning Diedrich <> wrote:
> Are you using insert(t,v) or insert(t,n,v)?

local append = table.insert
append(t,val)   -- n is implicit, #t

It's a tricky function, because it has two distinct ways of being
called. So I usually use this alias.

It would be useful if append(t,nil) was guaranteed to be a no-op.

insert(t,n,nil) can of course insert holes into an array, and I'm not
sure how useful this is. If it was a no-op, then it would be still
possible to insert a nil explicitly by inserting some other value and
doing t[n] = nil afterwards.

steve d.