Standard Library Tables
Pack Count
Use table.pack when nil values must still count as arguments.
Pack Count
pack_count.lua
local middle =
local count = table.pack("red", middle, nil).n
print("middle=" .. tostring(middle))
print("count=" .. count)
local middle =
local count = table.pack("red", middle, nil).n
print("middle=" .. tostring(middle))
print("count=" .. count)
local middle =
local count = table.pack("red", middle, nil).n
print("middle=" .. tostring(middle))
print("count=" .. count)
nil aware count
`table.pack(...).n` keeps the original argument count even when one argument is `nil`.