[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: __ipairs
- From: "Soni \"They/Them\" L." <fakedme@...>
- Date: Fri, 16 Mar 2018 07:04:57 -0300
On 2018-03-16 07:00 AM, Oliver Kroth wrote:
Uh, the only issue is that ipairs would "respect" nil, but otherwise
it does/should work.
But yes, being able to explicitly include nils in ipairs output, i.e.
with __ipairs, would be nice.
afaIk, getting nil from the iterator is what terminates the loop...
ipairs uses nil as a loop end
e.g.
t = {1, 2, 3, nil, 4}
for k, v in ipairs(t) do print(k,v) end
--[[
1 1
2 2
3 3
--]]
When using __index, it still stops on the first nil. It doesn't respect
__len.
This means tuples without nil in them would iterate fine:
for k, v in ipairs(tuple(1, 2, 3)) do print(k,v) end
--[[
1 1
2 2
3 3
--]]
But tuples with nil would stop short.
--
Disclaimer: these emails may be made public at any given time, with or without reason. If you don't agree with this, DO NOT REPLY.