Skip to content

Object and class inspection functions

Benct Philip Jonsson edited this page May 8, 2021 · 1 revision

These are some functions for class/object inspection:

Function Purpose
is_object Check if a value is a class or object.
is_class Check if a value is a class.
is_instance Check if a value is a (sub)class or an instance of a (sub)class

is_object(value [, name, ...])

Returns:

  • false if value is not an object or class, i.e. is not a table or does not have a field __class which is a table.
  • else with one argument: the name of (the class of) value, i.e value.__class.__name.
  • else with 2+ arguments: the name of (the class of) value if it equals one of the extra arguments, or else nil.