Version:

Module table

Module table

The table module has everything in the standard Lua table library, and some Tarantool extensions.

You can see this by saying “table”: you will see this list of functions: clear (LuaJIT extension = erase all elements), concat (concatenate), copy (make a copy of an array), deepcopy (see description below), foreach, foreach1, getn (get the number of elements in an array), insert (insert an element into an array), maxn (get largest index) move (move elements between tables), new (LuaJIT extension = return a new table with pre-allocated elements), remove (remove an element from an array), sort (sort the elements of an array).

In this section we only discuss the additional function that the Tarantool developers have added: deepcopy.

table.deepcopy(input-table)

Return a “deep” copy of the table – a copy which follows nested structures to any depth and does not depend on pointers, it copies the contents.

Parameters:
  • input-table – (table) the table to copy
Return:

the copy of the table

Rtype:

table

Example:

tarantool> input_table = {1,{'a','b'}}
---
...

tarantool> output_table = table.deepcopy(input_table)
---
...

tarantool> output_table
---
- - 1
  - - a
    - b
...