Lua中ipair和pair的区别
先看看官方手册的说明吧:
pairs(t)Ifthasametamethod__pairs,callsitwithtasargumentandreturnsthefirstthreeresultsfromthecall.
Otherwise,returnsthreevalues:thenextfunction,thetablet,andnil,sothattheconstruction
fork,vinpairs(t)dobodyend
williterateoverallkey–valuepairsoftablet.
Seefunctionnextforthecaveatsofmodifyingthetableduringitstraversal.
ipairs(t)Ifthasametamethod__ipairs,callsitwithtasargumentandreturnsthefirstthreeresultsfromthecall. Otherwise,returnsthreevalues:aniteratorfunction,thetablet,and0,sothattheconstruction fori,vinipairs(t)dobodyend williterateoverthepairs(1,t[1]),(2,t[2]),...,uptothefirstintegerkeyabsentfromthetable.
热门推荐
6 祝福语简短七夕
10 要过年了祝福语简短
11 虎年女孩出生祝福语简短
12 中考正能量祝福语简短
13 送女友表白祝福语简短
14 宝宝祝福语诗意简短 古文
15 女宝宝满月简短祝福语
16 同学分开祝福语简短
17 新婚祝福语简短句子
18 老师简短祝福语有哪些