【发布时间】:2014-05-29 10:47:59
【问题描述】:
假设我有这三个函数:
function getVector2D()
return 66.0, 77.0
end
function setVector2D(x, y)
print(x.." "..y)
end
function setVector3D(x, y, z)
print(x.." "..y.." "..z)
end
如果我使用setVector2D(getVector2D()),我没有问题,因为来自getVector2D 的多值返回将应用于setVector2D,结果将是66.0 77.0。
但是,如果我想部分应用以下参数怎么办:setVector3D(getVector2D(), 88.0)?
预期(和获得的)结果将仅是从getVector2D 评估的x,正如the manual 所说:
print(foo2(), 1) --> a 1print(foo2() .. "x") --> ax (see below)当对 foo2 的调用出现在表达式中时,Lua 会将结果数调整为 1;因此,在最后一行中,仅在连接中使用了“a”。
问题是:有什么方法可以在上面的调用中从getVector2D 获取多个值,并期望结果是66.0 77.0 88.0 干净的方式?
【问题讨论】:
标签: lua