लुआ मैनुअल से:
If index is a number, returns all arguments after argument number
index. Otherwise, index must be the string "#", and select returns
the total number of extra arguments it received.
Lua has built in multiple arguments, जिसे आप एक तालिका में परिवर्तित कर सकते हैं यदि आप वास्तव में जरूरत के लिए:
function multiple_args(...)
local arguments = {...} -- pack the arguments in a table
-- do something --
return unpack(arguments) -- return multiple arguments from a table (unpack)
end
अंत में, आप अगर इंडेक्स के रूप में "#" पास करें, फ़ंक्शन एकाधिक तर्क प्रदान करने की गिनती देता है डी:
print(select("#")) --> 0
print(select("#", {1, 2, 3})) --> 1 (single table as argument)
print(select("#", 1, 2, 3)) --> 3
print(select("#", {1,2,3}, 4, 5, {6,7,8}) --> 4 (a table, 2 numbers, another table)
यह website देखें।
स्रोत
2011-08-03 15:35:47
बीटीडब्ल्यू, लूप को 'str = table.concat ({str, ...}, "\ t") द्वारा प्रतिस्थापित किया जा सकता है। – lhf
मैं स्ट्रिंग को संयोजित करने के बजाय 'फ़ाइल: लिखना()' का उपयोग करने का सुझाव दूंगा और फिर 'os.execute() 'को कॉल करना बहुत तेज़ होगा। आप लाइन के अंत में फ़ाइल को 'फ्लश' करना चाह सकते हैं। –
अनुकूलन संकेतों के लिए धन्यवाद – AlexStack