Dallime mes rishikimeve të "Moduli:table/pack"
Jump to navigation
Jump to search
(Krijoi faqen me "--[==[ An implementation of the {table.pack} function found in Lua 5.2+, which returns a table containing a list of the arguments passed. The returned table also contains the key {n}, which is an integer giving the number of arguments passed. Note that the list in the returned table will contain gaps if any of the arguments passed were {nil}. This will also be reflected in the value of {n}, which always matches the number of arguments passed (e.g. {pack("foo")} returns th...") |
(Pa ndryshime)
|
Versioni aktual i datës 10 gusht 2025 09:07
Udhëzuesi për këtë modul mund të krijohet te Moduli:table/pack/doc.
--[==[
An implementation of the {table.pack} function found in Lua 5.2+, which returns a table containing a list of the arguments passed. The returned table also contains the key {n}, which is an integer giving the number of arguments passed.
Note that the list in the returned table will contain gaps if any of the arguments passed were {nil}. This will also be reflected in the value of {n}, which always matches the number of arguments passed (e.g. {pack("foo")} returns the table { {"foo", n = 1} }, whereas {pack("foo", nil, nil)} returns { {"foo", n = 3} }).]==]
return table.pack or function(...)
-- On Lua 5.1, use the hidden `arg` variable with `...`, which is the same
-- as table.pack(...) on Lua 5.2+. Both are strictly equivalent to
-- {n = select("#", ...), ...}, but more performant.
return arg
end