[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: ipairs in Lua 5.3.0-alpha
- From: Sean Conner <sean@...>
- Date: Tue, 19 Aug 2014 13:01:22 -0400
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 ... )