lua-users home
lua-l archive

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



>> `pairs` is actually building me a custom iterator closure which
>> it returns as its first result.
> 
> It may feel like that but in fact `pairs` simply returns `next,tbl,nil.`

I wasn't clear, I meant that I feel the purpose of `__pairs` is that it allows me to build a custom iterator.  I know that without a metamethod it just returns the `next` function.  Using the `__pairs` metamethod I can create exactly the examples you give.