[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua 5.3 `ipairs` considered perilous
- From: Mason Bogue <scythe+lua@...>
- Date: Wed, 17 Feb 2016 17:48:49 -0800
>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.