数组的逆序,只能用于数组,,不能用于哈希表
function reverseTable(tab)local tmp = {}for i = 1, #tab dolocal key = #tabtmp[i] = table.remove(tab)endreturn tmpend// 示例local t = {"one", "two", "three"}for k, v in pairs(t) doprint(k, v)endt = reverseTable(t)for k, v in pairs(t) doprint(k, v)end
输出:
1one2two3three1three2two3one
再发展下来才有了:大霞美的花卉基地和清源山的花博园。