你可以在没有解压缩的情况下将表转换为vararg吗?

Ske*_*ere 2 lua variadic-functions

有没有办法在不使用lua内的unpack的情况下将数字顺序表作为vararg返回?换一种说法; 你能重新打开解包功能吗?

示例表:

foo = {1, 2, 3}
Run Code Online (Sandbox Code Playgroud)

功能示例:

function unpackTable( tab )
    --
end
Run Code Online (Sandbox Code Playgroud)

要求的结果:

1, 2, 3
Run Code Online (Sandbox Code Playgroud)

mot*_*eus 7

local unpackTable do 

local function unpackTable_( tab, i, ... )
  if i == 0 then return ... end
  return unpackTable_( tab, i-1, tab[i], ...)
end

unpackTable = function( tab )
  return unpackTable_(tab, #tab)
end

end

foo = {1, 2, 3}
print(unpackTable(foo))
Run Code Online (Sandbox Code Playgroud)