[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: When does __index metamethod get called?
- From: "Jerome Vuarand" <jerome.vuarand@...>
- Date: Thu, 16 Mar 2006 18:31:18 -0500
__newindex is used for any write to he
table.
__index is a getter, __newindex is the
setter.
Doub.
Example:
tbl = {}
setmetatable(tbl, {__index = function(t,k) print("test") end})
tbl[1] = 1
tbl[2] = 2
Prints nothing... ??
Also, is there any metamethod that you can hook to know when a value is
being set? I know there is __newindex but that only appears to be called
for new values being inserted into the table. I want to hook both cases of
new values and also setting existing values.
--
//
Chris