如 table.foreachi(),会期望一个从 1(数字 1)开始的连续整数范围:
> table.foreachi(t1, print) 1 moustache 2 3
另外一些函数,例如 table.foreach(),会对整个表进行迭代:
> table.foreach(t2,print) 1 groucho 3 chico 5 harpo > table.foreach(t1,print) 1 moustache 2 3 brothers true
尽管有些迭代器对整数索引进行了优化,但是所有迭代器都只简单地处理 (key, value) 对。
现在我们可以创建一个表页码:[1] [2] [3] [4] [5] [6] [7] 第4页、共7页 |