lua-users home
lua-l archive

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


>neat solutions to the problem would have been possible.

It doesn't even need to be that much longer:

function __index(self, k) return type(k) == "number" and k <= #self
and 0/0 or nil end

I don't think it's too much of a burden to write what you actually
mean in the __index metamethod. If the __index() returns non-nil
values for positions that should be nil, it's because your code is
wrong, not Lua.