Does anybody know actual implementation of lua 5.2. metamethod __pairs
? In other words, how do I implement __pairs
as a metamethod in a metatable so that it works exactly same with pairs()
?
I need to override __pairs
and want to skip some dummy variables that I add in a table.
The following would use the metatable meta to explicitly provide
pairs
default behavior:Now, for skipping specific elements, we must replace the returned
next
:For reference: Lua 5.2 manual, pairs
The code below skips some entries. Adapt as needed.