示例工程 05-variables-and-scope
05-variables-and-scope/03-multi-assign-truncation/main.lua
-- @runtimes lua54 luajit
--- 演示:多重赋值的截断、扩展与右侧多重返回。
local M = {}
local function three()
return 1, 2, 3
end
--- @return table { a = any, b = any, c = any, m = any, n = any }
function M.run(log)
log = log or print
local a, b, c = 1, 2
local m, n = three()
local p, q = three(), 10
log(("a=%s b=%s c=%s"):format(tostring(a), tostring(b), tostring(c)))
log(("m=%s n=%s"):format(tostring(m), tostring(n)))
log(("p=%s q=%s"):format(tostring(p), tostring(q)))
return { a = a, b = b, c = c, m = m, n = n, p = p, q = q }
end
if not ... then
M.run()
end
return M