unpack它接受一個(gè)數(shù)組(table)作為參數(shù),并默認(rèn)從下標(biāo)1開始返回?cái)?shù)組的所有元素,例子代碼如下:
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
標(biāo)簽:天門 天門 德宏 儋州 金昌 臺(tái)灣 宣城 濰坊
巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《Lua UnPack函數(shù)用法實(shí)例》,本文關(guān)鍵詞 Lua,UnPack,函數(shù),用法,實(shí)例,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。