I’m trying to print the new key added into the table
After making a new key and setting the value into the “normal” table and then trying
to print the new value of the key in the table, it prints nil for some reason.
I’m trying to learn meta tables, but this is really confusing and i cant find help.
I thought it was only supposed to say that the “key was added” like i told it to
but clearly its doing something else to the value and making it non existant.
local normal = {}
local meta = {
__newindex = function(t, k)
print(k.." added")
return "default"
end,
}
setmetatable(normal, meta)
normal.x = 25
print(normal.x) -- Prints nil