lua-users home
lua-l archive

Re: ipairs in Lua 5.3.0-alpha

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


It was thus said that the Great Dirk Laurie once stated:
> 2014年08月19日 18:45 GMT+02:00 Sean Conner <sean@conman.org>:
> > Now, __pairs or __ipairs don't exist in Lua 5.1 and of the two, I regret
 ^^^^^^^
> > not having __pairs. I can work around __ipairs with
> >
> > for i = 1 , #userdata do ... end
> >
> > __pairs, not so much [1].
> >
> > -spc
> >
> > [1] Okay, I can work around it with a very clumsy:
> >
> > udindex = { 'foo' , 'bar' , 'baz' }
> > for _,idx in ipairs(udindex) do
> > local item = userdata[idx]
> > ...
> > end
> 
> Doesn't
> 
> for k,v in userdata:__pairs() do
> 
> where __pairs sits in you userdata's __index, do it?
 -spc (Lua 5.1 only for now ... )

AltStyle によって変換されたページ (->オリジナル) /