在 2017年1月17日,下午10:12,云风 Cloud Wu <cloudwu@gmail.com> 写道:hz <hz@fiosoftware.com>于2017年1月18日周三 下午1:43写道:just a little inconvenient when used with: for k, v in pairs(obj) do … endthe keys in the realobj will be ignored. It's a known issue:Why don't pairs() and ipairs() obey an __index metamethodhttp://lua-users.org/lists/lua-l/2007-09/msg00374.htmlYou can use __pairs metamethod like this :__pairs = function(t) return next, realobj, nil end
just a little inconvenient when used with: for k, v in pairs(obj) do … endthe keys in the realobj will be ignored. It's a known issue:Why don't pairs() and ipairs() obey an __index metamethodhttp://lua-users.org/lists/lua-l/2007-09/msg00374.html