The table module
The table module provides the metatable for the table type. It contains various functions for manipulating tables.
Member functions
clone(self): table
Returns a shallow copy of the table self.
getOrDefault(self, key: any, default: any): any
Returns the value of the key key in the table self. If the key does not exist, returns default.
merge(self, other: table): null
Merges the table other into self. If a key exists in both tables, the value from other is used.
keys(self): list
Returns a list of all keys in the table.
remove(self, key: any): null
Removes the key key from the table self and returns the value mapped to it. If the key does not exist, raises KeyError.
size(self): number
Returns the number of keys in the table.
values(self): list
Returns a list of all values in the table.
Metamethods
__contains__(self, key: any): boolean
Returns true if the key key exists in the table self, false otherwise.
__index__(self, key: any): any
Returns the value of the key key in the table self. If the key does not exist, raises KeyError.
__plus__(self, other: table): table
Returns a new table containing the contents of self and other. If a key exists in both tables, the value from other is used.
__set__(self, key: any, value: any): null
Sets the value of the key key in the table self to value.