lua-users home
lua-l archive

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



On 18 Nov 2010, at 09:14, starwing wrote:
how can I insert the multi return value from a function to a middle of a table?

e.g. fh:write("line: ", ..., "\n")

  function append(val, ...)
  	local c = select("#", ...)+1
  	return unpack({[c] = val, ...}, 1, c)
  end

  fh:write("line: ", append("\n", ...))

Also check the link below for a more efficient implementation of 'append' using the C API.

  http://www.tecgraf.puc-rio.br/~maia/lua/vararg/

--
Renato Maia
Computer Scientist
Tecgraf/PUC-Rio
__________________________
http://www.inf.puc-rio.br/~maia/