#How does __newindex actually work in OOP? (WILL PAY)
15 messages · Page 1 of 1 (latest)
__newindex is essientally just a function that fires when an new index is assigned to
local metatable = {}
metatable.__newindex = function(t, i, v)
print(`t[{i}] was assigned to. v: {v}`)
end
local t = setmetatable({
x = 1
}, metatable)
t.x = 2 -- will print, since x is being assigned to.
doSomething(t.y) -- will not print, since it's being accessed. (use __index for that.)
so essientally, if it exists, __newindex will only fire if you're adding something that didn't already exist to the dictionary
How about detect changes of properties ?

what?
that's probably a better way to say it
uhh
i want it fires when i change the index that already exists
Is there any way?
just check if it already exists
like the .Changed event for instance
