Roblox What Is The Difference Between Index And Newindex

[Solved] Roblox What Is The Difference Between Index And Newindex | Lua - Code Explorer | yomemimo.com
Question : roblox what is the difference between __index and __newindex

Answered by : tomsterbg

myMetaTable = {	__index = function(table, index)	print("Sorry, but the element ".. tostring(index).. " does not exist.")	-- runs when you try to index a nil element of the table this metatable is connected to, table[index]	end,	__newindex = function(table, index, value)	print("Sorry, but the element ".. tostring(index).. " can't be set to ".. tostring(value).. " because this element does not exist.")	-- runs when you try to index and set a nil element of the table this metatable is connected to, table[index] = value	end
}

Source : | Last Update : Thu, 14 Jul 22

Answers related to roblox what is the difference between index and newindex

Code Explorer Popular Question For Lua