[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: unpack in lua5.1
- From: al_lea <abrash_han@...>
- Date: Wed, 29 Nov 2006 03:48:30 +0000 (UTC)
hi,
I'd just port some code from lua5.0 to 5.1 and found that unpack(arg) doesn't
work as expected.
code sample:
g_load_new =
{
[1] = "arcaves.lua",
[4] = 1,
n = 4,
}
function foo(...)
print(unpack(arg))
print(arg.n)
end
foo(unpack(g_load_new))
-- end --
in 5.0 the output is:
arcaves.lua nil nil 1
4
in 5.1 the output is:
arcaves.lua
1
Is there some way to make the unpack works well with nil holes? like this (PiL,
chap 5.2):
"Sometimes, a function with a variable number of arguments needs to pass them
all to another function. All it has to do is to call the other function using
unpack(arg) as argument: unpack will return all values in arg, which will be
passed to the other function. "
Thanks,
hZ