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 祖国七十华诞简短祝福语