Is there something like __newindex that also fires when index is not nil?

local tab = setmetatable({}, {
__newindex = function(tbl, key, value)
rawset(tbl,key,value)
print("value changed!")
end)

tab["hi"] = 1
tab["hi"] = 5

^^ how to make this print twice

There is not, though you can use a proxy table for that.

Read

and the next post

2 Likes