2,875
edits
(Add function overrides (as far as possible in Lua anyway) to first and firstordefault) |
(Define metatable outside of ctor) |
||
Line 1: | Line 1: | ||
local funlist = {} | local funlist = {} | ||
funlist. | local funlist_mt = { | ||
__index = funlist, | |||
__pairs = function(t) return pairs(t.mytable) end, | |||
__ipairs = function(t) return ipairs(t.mytable) end | |||
} | |||
-- Constructor | -- Constructor | ||
function funlist.new(tbl) | function funlist.new(tbl) | ||
assert(type(tbl) == 'table') | assert(type(tbl) == 'table', 'Value must be a non-nil table.') | ||
local self = setmetatable({}, funlist_mt) | |||
self.mytable = tbl | self.mytable = tbl |
edits