Module util

Returns whether a table includes a certain element.

Functions

util.table.is (t) Returns whether or not its argument is a table
util.table.map (t, fn) Applies a function to every element of a table and collects the results in a new table.
util.table.for_each (t, fn) Applies a function to each element of a tabla and throws away the results.
is_instance_of (instance, class) Returns whether an object is an instance of a certain class.
util.deco.if_condition (condition) Given a condition, returns a function that returns either its first argument (if condition is true) or its second argument (if condition is false)
util.value.not_nil (value, default) Checks whether a value is nil and returns a default value if so.


Functions

util.table.is (t)
Returns whether or not its argument is a table

Parameters:

  • t Any value

Returns:

    boolean Whether t is a table
util.table.map (t, fn)
Applies a function to every element of a table and collects the results in a new table. Arguments passed to the function are Value, Key and the Table.

Parameters:

  • t table A table of values
  • fn function A function to apply to every value

Returns:

    table The return values of each call to fn
util.table.for_each (t, fn)
Applies a function to each element of a tabla and throws away the results. Arguments passed to the function are Value, Key and the Table.

Parameters:

  • t table A table of values
  • fn function A function to apply to every value
is_instance_of (instance, class)
Returns whether an object is an instance of a certain class.

Parameters:

  • instance table The object to check
  • class string The class name the object might be an instance of

Returns:

    boolean Whether the object is an instance of the class
util.deco.if_condition (condition)
Given a condition, returns a function that returns either its first argument (if condition is true) or its second argument (if condition is false)

Parameters:

  • condition Any Lua value

Returns:

    function One of the two functions described above
util.value.not_nil (value, default)
Checks whether a value is nil and returns a default value if so.

Parameters:

  • value Value to check if is nil
  • default Value to return if value param is nil

Returns:

    default if value is nil, value otherwise
generated by LDoc 1.4.6 Last updated 2019-05-06 01:56:35