object: Module Index

# Module `object`

Prototype-based objects

- Create an object/class:

- Either, if the `_init` field 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 `_init` field is a function:
  - `object/Class = prototype (value, ...)`
  - The given values are passed as arguments to the `_init` function.
- 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

## Tables

Object
  Root object

  ### Fields

  - _init: constructor method or list of fields to be initialised by the constructor
  - _clone: object constructor which provides the behaviour for `_init` documented above