July 2018
Beginner
202 pages
5h 42m
English
Even if a table has an __index or __newindex meta method, values in that table can still be set directly. These meta methods can be bypassed with the rawset and rawget functions, which set and get the values of a table directly.
rawget takes two arguments, the table being accessed and the key being retrieved. It has the following signature:
rawget(table, key)
rawset takes three arguments, the table being accessed, the key being set, and the value being set. It has the following signature:
rawset(table, key, value)
To demonstrate how this works, let's use the previous sample code to set the foo member of table x directly:
x = { }y = { }z = { __index = function(table, key) return z[key] end, __newindex = function(table, key, ...