unpack它接受一个数组(table)作为参数,并默认从下标1开始返回数组的所有元素,例子代码如下:
function returnMoreValues()
return 1, 2, 3;
end
a, b, c = returnMoreValues();
--print(a, b, c);
--print((returnMoreValues()));
--print(arrayData); -- print the address of the arrayData
--print(unpack(arrayData)); -- print all the elements of the arrayData
print(unpack(arrayData, 2)); --the second param is the index of the arrayData
end
新闻热点
疑难解答