Table Extensions
Ratchet expands on the standard table library to give you a few more functions for convenience. All standard Lua functions are available as well and not listed on this page.
copy
function
Creates a deep copy of a table to break reference from the original.
Syntax:
lua
table table.copy( table original )
merge
function
Merges multiple tables into one. Any amount of tables can be specified.
Syntax:
lua
table table.merge( [ table first, ... ] )
swap
function
Swaps keys with values in a table.
Syntax:
lua
table table.swap( table original )
reverse
function
Syntax:
lua
table table.reverse( table original )
shuffle
function
Syntax:
lua
table table.shuffle( table original )
keys
function
Syntax:
lua
table table.keys( table list )
values
function
Syntax:
lua
table table.values( table list )
contains
function
Syntax:
lua
bool table.contains( table list, mixed value )
isEmpty
function
Checks whether a table is completely empty.
Syntax:
lua
bool table.isEmpty( table list )
count
function
Returns the number of keys in a table, effectively counting the number of elements.
This should be used for non-sequential tables, otherwise standard #
is more efficient.
Syntax:
lua
int table.count( table list )
random
function
Returns a random value from the table.
Syntax:
lua
mixed table.random( table list )