[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Next Version of Lua?
- From: steve donovan <steve.j.donovan@...>
- Date: Wed, 10 Jun 2009 14:57:27 +0200
On Wed, Jun 10, 2009 at 2:49 PM, Peter Cawley<lua@corsix.org> wrote:
> Or, alternatively, using the undocumented behaviour of ipairs:
>
> ipairs_next = ipairs{}
> t = {"hello", "world", "from", "Lua"}
> setmetatable(t, {__call = function(t,_,i) return ipairs_next(t, i or 0) end})
> for k, v in t do print(k, v) end
Very elegant - actually, it is documented that the ipairs() function
would return 'an iterator function' as its first result.