lua-users home
lua-l archive

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


On 1 March 2011 22:49, Tony Finch <dot@dotat.at> wrote:
> table.insert() should have its two-argument form separated out into a
> table.append() function - which could quite nicely append multiple values.

I have found my own version of table.append() useful when adding
strings piecemeal in preparation for a big table.concat().

On 1 March 2011 23:15, Daurnimator <quae@daurnimator.com> wrote:

> Agreed; this is the most sensible/basic fix for the case of table.insert
> Though I might even suggest the elimination of table.append entirely;
> it's so trivial to create:
> tblappend = function ( t , v ) t [ #t + 1 ] = v ; return v end

But a good table.append() function will be able to take more than one
argument. If you used an 'n' field you could even deal with trailing
nils, if that is your thing!

Vaughan