Module pl.types

Dealing with Detailed Type Information

Functions

is_callable (obj) is the object either a function or a callable object?.
is_type (obj, tp) is the object of the specified type?.
type (obj) a string representation of a type.
is_integer (x) is this number an integer?
is_empty (o, ignore_spaces) Check if the object is "empty".
is_indexable (val) is an object 'array-like'?
is_iterable (val) can an object be iterated over with `ipairs`?
is_writeable (val) can an object accept new key/pair values?
to_bool (o[, true_strs[, check_objs]]) Convert to a boolean value.


Functions

is_callable (obj)
is the object either a function or a callable object?.

Parameters:

  • obj Object to check.
is_type (obj, tp)
is the object of the specified type?. If the type is a string, then use type, otherwise compare with metatable

Parameters:

  • obj An object to check
  • tp String of what type it should be
type (obj)
a string representation of a type. For tables with metatables, we assume that the metatable has a `_name` field. Knows about Lua file objects.

Parameters:

  • obj an object

Returns:

    a string like 'number', 'table' or 'List'
is_integer (x)
is this number an integer?

Parameters:

  • x a number

Raises:

error if x is not a number
is_empty (o, ignore_spaces)
Check if the object is "empty". An object is considered empty if it is nil, a table with out any items (key, value pairs or indexes), or a string with no content ("").

Parameters:

  • o The object to check if it is empty.
  • ignore_spaces If the object is a string and this is true the string is considered empty is it only contains spaces.

Returns:

    true if the object is empty, otherwise false.
is_indexable (val)
is an object 'array-like'?

Parameters:

  • val any value.
is_iterable (val)
can an object be iterated over with `ipairs`?

Parameters:

  • val any value.
is_writeable (val)
can an object accept new key/pair values?

Parameters:

  • val any value.
to_bool (o[, true_strs[, check_objs]])
Convert to a boolean value. True values are: * boolean: true. * string: 'yes', 'y', 'true', 't', '1' or additional strings specified by `true_strs`. * number: Any non-zero value. * table: Is not empty and `check_objs` is true. * object: Is not `nil` and `check_objs` is true.

Parameters:

  • o The object to evaluate.
  • true_strs optional Additional strings that when matched should evaluate to true. Comparison is case insensitive. This should be a List of strings. E.g. "ja" to support German. (optional)
  • check_objs True if objects should be evaluated. Default is to evaluate objects as true if not nil or if it is a table and it is not empty. (optional)

Returns:

    true if the input evaluates to true, otherwise false.
generated by LDoc 1.4.6 Last updated 2021-01-03 11:25:39