lua-users home
lua-l archive

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



On 11 Jan 2017, at 10:34, Chris Lu <[email protected]> wrote:

Hi,

I am using LuaJIT. I need to pass the result of one function to another function. The first function has multiple return values. This is the code I am using.

  local t = {functionFirst()}
  functionSecond(unpack(t))

This works mostly, but fails if one of the return value is nil. The first function is defined by the end user, so I can not control it.

How to detect the number of return values? If I can know how many values are returned from first function,  this should work.

  functionSecond(unpack(t, 1, count))

Thanks!

Chris

see http://lua-users.org/lists/lua-l/2010-01/msg01427.html

Thijs