首页 > 代码库 > 有趣的事

有趣的事

for i in print, "123" , "368" doend输入:123 368function iter (a, i) i = i + 1 local v = a[i] if v then return i, v endenda = {"one", "two", "three"}for i, v in iter, a, 0 do print(i, v)end输出:1 one 2 two 3 three注:in会执行放入的函数并将后续变量作为参数传入函数中

有趣的事