[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Definition of table.insert
- From: steve donovan <steve.j.donovan@...>
- Date: Sun, 9 Jan 2011 07:14:44 +0200
On Sat, Jan 8, 2011 at 11:54 PM, Henning Diedrich <hd2010@eonblast.com> 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.