Module object
Prototype-based objects
- Create an object/class:
- Either, if the
_initfield is a list:object/Class = prototype {value, ...; field = value, ...}- Named values are assigned to the corresponding fields, and unnamed values to the fields given by
_init.
- Or, if the
_initfield is a function:object/Class = prototype (value, ...)- The given values are passed as arguments to the
_initfunction.
- An object's metatable is itself.
- Private fields and methods start with "
_". - Access an object field:
object.field - Call an object method:
object:method (...) - Call a class method:
Class.method (object, ...) - Add a field:
object.field = x - Add a method:
function object:method (...) ... end
Tables
| Object | Root object |