An example:
1
2
2
t = { age = 42, height = 102 } m = { __add = function (tbl, n) return t.age + n end }
Would be appreciated
t = { age = 42, height = 102 } m = { __add = function (tbl, n) return t.age + n end }
t = { age = 42, height = 102 } m = { --called when we use the '+' operator on the given 'tbl' __add = function (tbl, n) return tbl.age + n end } --Make it so the table 't' gets the metatable 'm' setmetatable(t, m) print(t + 3) --would be t.age + 3, so we expect 42 +3 aka 45
tostring(yourTable)with your table etc.