Actually does a full copy of a table, instead of referencing the original. This also recursively copies sub-tables.
Functions and userdata/C classes cannot be copied directly and so will be left as references to
the original data. Built-in Lua data types, such as
The tables' metatable will also be copied, as well.
Merges the contents of two or more tables into a new table. That is, all of the elements of each table are condensed down to a single table. You may pass as many tables as you would like to this method, but every parameter must be a table. Nested tables are acceptable, but these will be copied instead.
Items keyed by integers (ie. array style) will not retain their keys, but will all be included even if there are duplicates.
All other items (ie. key-value pairs, dictionary, map style) may overwrite each other, with the later being given precedence.
For example, if the first and second tables passed to table.merge() both contain a
Be aware that metatables will not be merged as part of this process.
Checks table 'haystack' for anything that matches 'needle'. If found, returns the table's key that
contains the value. If no match is found, returns
'needle' can be any data type. The key returned depends entirely on the structure of 'haystack' and
will be either a
Recursively dump the table to the standard output. This is useful for debugging. When called from Lua, you probably shouldn't include the depth...
Due to how Lua iterates over tables that are not indexed in the format of 1..n (aka a list, ie. if your table uses any keys that are non-sequential starting at 1, or contain any strings), the order in which items are iterated over is unpredictable. In the below example, you will see that 'age' is output before 'name' because of this, however the 'favoriteFoods' table maintains it's order.
Return a new
If only 'field' is given, the returned
That makes absolutely no sense, so just look at this example instead.
Page last updated at 2024-04-02 14:32:32