I want to learn how to use metamethods but I don't understand the principle. The code belows not work, when I print a inexistant value the script return nil. But in the tutorial its working good, why? What I doesn't understand?
local myName = {
josh = 10,
tony = 15
}
local yourName = {
morice = 30
}
local metamethod = {
_index = myName.josh
}
setmetatable(yourName, metamethod)
print(yourName.josh) -- return nil

1 comment
Thanks you!:D