- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有这个测试函数,它只是打印传递给它的值
function test1(...)
for k, v in ipairs(arg) do
print(v)
end
end
function test2(...)
for k, v in pairs(arg) do
print(v)
end
end
-- GOOD behavior
test1(1, 2, 3, 4) -- produces 1 2 3 4
test2(1, 2, 3, 4) -- produces 1 2 3 4
-- BAD behavior
test1( unpack({1,2}), 3, 4) -- produces 1 3 4
test2( unpack({1,2}), 3, 4) -- produces 1 3 4 3
最佳答案
此行为并非特定于 unpack
.
Lua Reference Manual说:
"Both function calls and vararg expressions can result in multiple values. If a function call is used as a statement (see §3.3.6), then its return list is adjusted to zero elements, thus discarding all returned values. If an expression is used as the last (or the only) element of a list of expressions, then no adjustment is made (unless the expression is enclosed in parentheses). In all other contexts, Lua adjusts the result list to one element, either discarding all values except the first one or adding a single nil if there are no values."
关于Lua unpack() 乱七八糟的参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29892079/
我关于套接字的代码分为三个类,现在我已经研究它(并学习套接字 Api)几个小时了,我已经把它归结为只剩下一个错误(我可以看)。从服务器收到的消息将不会打印,而是抛出此错误。 Exception in
当我打开个人热点连接时,我的布局被下推。我怎样才能删除顶部的这个热点栏或者得到这个栏的通知并根据它重新排列我的 View ?谢谢。 最佳答案 当状态栏的大小发生变化时,将调用您的应用程序委托(dele
我正在编写一个 Chrome 扩展,它在现有页面的顶部插入一个 DIV。我为我的 DIV 指定了不同的 ID 名称“juxiSidebar”。此外,我插入到页面中的所有 ID 和类都包含前缀“juxi
我正在为我的工作创建一个 Javascript 框架,支持最现代的浏览器(FF 4+、Chrome、Opera 11+、IE8+)。我在尝试扩展 prototype 时遇到了一些问题样式规则(假设 r
我是一名优秀的程序员,十分优秀!