想输出 “1,2,3"的时候 以前的写法都是
local testTable ={"1","2","3"}
local step = 1
local tableCount = #testTable
for key, var in pairs(testTable) do
destStr = destStr..var
if step ~= tableCount then
destStr = destStr..","
end
step = step + 1
end
知道Next之后就简便一些
local testTable ={"1","2","3"}
local destStr = ""
for key, var in pairs(testTable) do
destStr = destStr..var
if next(testTable,key) then
destStr = destStr..","
end
end
print ("destStr==="..destStr)