lua-users home
lua-l archive

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

On Thu, Feb 21, 2008 at 2:32 AM, Jérôme Vuarand <> wrote:

Why is the new ipairs using an __ipairs metamethod rather than the
existing __index ?

__index works when the caller tries to access a given key. __pairs/__ipairs must be able to enumerate all available keys. Moreover, there are cases where you can provide __index but where no __pairs would make sense (typically when there's an infinite number of virtual keys).