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.
热门推荐
10 新年祝福语简短的感谢
11 简短元旦祝福语古言
12 小朋友得奖祝福语简短
13 开业祝福语大全简短赞美
14 长辈请客祝福语简短精辟
15 节日祝福语简短中秋暧昧
16 新房上梁简短祝福语大全
17 别人的新年祝福语简短
18 部门过年祝福语简短独特