[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: table.insert
- From: Patrick Donnelly <batrick@...>
- Date: Sun, 7 Feb 2010 23:19:23 -0500
On Sun, Feb 7, 2010 at 6:50 AM, Wim Langers <wim.langers@adrias.biz> wrote:
> Just something that struck me as being odd the other day...
> table.insert(table[,pos],data)
> --> has the second parameter optional instead of the third ?
> switching this to
> table.insert(table,data[,pos])
> would, beside a perhaps unprecedented level of incompatibility between
> versions, give the advantage of being able to use a position parameter
> calculated from "unusual" conditions (that return a nil result to indicate
> out of range parameters or such).
Use this:
table.insert(table, getpos(...) or #t+1, data)
where #t+1 is the default position for table.insert (or whatever you
want the default to be).
--
- Patrick Donnelly