Module tableutil

Various utility functions for working with tables.

Functions

clone (table) Performs a deep/recursive clone on the given table.
comparator (a, b) A comparator function that can be used for sorting a table with different value types.
equals (a, b) Tests the two given tables for equality.
keys (...) Returns a (unique) list with all keys of all tables.
merge (...) Merges the given tables into one instance.
to_string (table, one_line, table_ids, indent) Returns the string representation of the given table.


Functions

clone (table)
Performs a deep/recursive clone on the given table.

Parameters:

  • table The table to deep clone.

Returns:

    The clone of the table.
comparator (a, b)
A comparator function that can be used for sorting a table with different value types. It sorts numbers first, after that strings, tables and nil.

Parameters:

  • a The first value.
  • b The second value.

Returns:

    true if the first value is less than (should come before) the second.
equals (a, b)
Tests the two given tables for equality.

Parameters:

  • a The first table.
  • b The second table.

Returns:

    true if the tables are equal.
keys (...)
Returns a (unique) list with all keys of all tables.

Parameters:

  • ... The list of tables.

Returns:

    A list with all keys.
merge (...)
Merges the given tables into one instance. Note that no cloning is performed so fields may refer to the same instances.

Parameters:

  • ... The tables to merge.

Returns:

    The merged table.
to_string (table, one_line, table_ids, indent)
Returns the string representation of the given table.

Parameters:

  • table The table.
  • one_line Optional. If the table should be printed on only one line. Defaults to false.
  • table_ids Optional. If the table IDs should be printed. Defaults to true.
  • indent Optional. The number of spaces of indentation.

Returns:

    The string representation of the given table.
generated by LDoc 1.4.2