lua-users home
lua-l archive

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




On 04/03/15 04:44 PM, Tom N Harris wrote:
On Wednesday, March 04, 2015 01:21:46 PM Soni L. wrote:
The string metatable has __index which is an empty sequence.
debug.setmetatable(nil, {__index=function() return nil end})
for _ in ipairs(nil) do end -- no error

ipairs returns different iterators depending on whether there is an __index
metamethod. One side effect is you can't use the same iterator with different
types. Not that any reasonable person would want to do that.

So you can't change the metamethods (e.g. add __index) while iterating?

--
Disclaimer: these emails are public and can be accessed from <TODO: get a non-DHCP IP and put it here>. If you do not agree with this, DO NOT REPLY.