lua-users home
lua-l archive

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


Hi

On Mon, May 04, 2009 at 11:05:14AM -0400, V S P wrote:
> what's a way to anticipate the last iteration
> in loop over a table
> 
> for colnm, coltype in pairs(tb_columns) do
> 
unroll the magic for statement
http://www.lua.org/manual/5.1/manual.html#2.4.5

and use next(tb_columns) directly
http://www.lua.org/manual/5.1/manual.html#pdf-next


However, if you want something be done at the end of each
but the last iteration (like printing a ',') you
might as well do it at the start of each but the first one.


cheers
Klaus