https://github.com/tst2005/lua-vararg
https://github.com/tst2005/lua-vararg
lua to-be-released
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/tst2005/lua-vararg
- Owner: tst2005
- Created: 2019-03-08T11:59:13.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-03-08T16:54:37.000Z (over 7 years ago)
- Last Synced: 2025-04-06T02:41:12.265Z (about 1 year ago)
- Topics: lua, to-be-released
- Language: Lua
- Size: 1.95 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# lua-vararg
A simple way to pack/unpack variable arguments.
The main feature is to correctly deals with nil values.
```lua
local vararg = require "vararg"
local function pack(...)
return {...}
end
print(table.unpack(pack(1, 2, nil, 3, nil))) -- 1 2
print(vararg.unpack(vararg.pack(1, 2, nil, 3, nil))) -- 1 2 nil 3 nil
print(vararg(1, 2, nil, 3, nil):unpack()) -- 1 2 nil 3 nil
```