作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在使用隐式参数 arg
时遇到问题在函数中。
该代码不起作用。文档,http://www.lua.org/pil/5.2.html ,应该有效。
function listar_um (...)
for i,v in ipairs(arg) do
print("usando args " .. arg[i])
end
end
listar_um("Olá", 1, "Dois")
lista
.
function listar_um (...)
lista = {...}
for i,v in ipairs(lista) do
print("não usando args " .. lista[i])
end
end
listar_um("Olá", 1, "Dois")
最佳答案
The first edition of PiL谈论 Lua 5.0。 arg
的使用在 Lua 5.0 中可用,而在 Lua 5.1 后被移除
您可以在 Lua 5.0 reference manual 中找到它,但不在 Lua 5.1 reference manual .
版本the online interpreter使用的是Lua 5.2,你可以通过print(_VERSION)
找到.
编辑 : 经过一些测试,似乎arg
在 Lua 5.1 中仍然可用,但在 Lua 5.2 中不起作用。
关于lua - 函数中的参数隐式 "arg"在 Lua 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25664301/
我是一名优秀的程序员,十分优秀!