lua

Table Extensions

class table

The following are extensions to the Lua table class.

flatten(t)

Flattens a table into a single array.

Parameters:

t (table) – The table to flatten

Returns:

A flattened array

Return type:

table

t = {1, 2, {3, 4, {5, 6}}}
print(table.flatten(t)) -- {1, 2, 3, 4, 5, 6}