t(t1., t2., t5.films) nil nil nil
> -- even a function can be a key > t = {} > function t.add(i,j) >> return(i+j) >> end > print(t.add(1,2)) 3 > print(t['add'](1,2)) 3 > -- and another variation of a function as a key > t = {} > function v(x) >> print(x) >> end > t[v] = "The Big Store" > for key,value in t do key(value) end The Big Store
正如我们可能期望的一样,Lua 还提供了很多迭代器函数来对表进行处理。全局变量 table 提供了这些函数(是的,Lua 包就是表)。有些函数,例页码:[1] [2] [3] [4] [5] [6] [7] 第3页、共7页 |