【发布时间】:2015-03-31 05:26:51
【问题描述】:
如何在shortdesc 中使用title?
这失败了:
function descriptor()
return {
title = "This";
shortdesc = title .. " is my text."
}
end
【问题讨论】:
标签: function variables lua return lua-table
如何在shortdesc 中使用title?
这失败了:
function descriptor()
return {
title = "This";
shortdesc = title .. " is my text."
}
end
【问题讨论】:
标签: function variables lua return lua-table
你不能;你可以使用局部变量:
function descriptor()
local title = "This"
return {
title = title;
shortdesc = title .. " is my text."
}
end
【讨论】:
保罗是正确的。您也可以分段构建表格:
function descriptor()
local t = {}
t.title = "This";
t.shortdesc = t.title .. " is my text."
return t
end
【讨论】: