instance
Methods on every class instance.
Call these with .$
An instance's members and its built-in methods share one namespace, and a member wins. An instance that declares a field called rawget, tostring or weakref hides the method of that name, and the ordinary call then fails with attempt to call 'string' or whatever the field happens to hold.
Writing the call as obj.$rawget(key) reaches the built-in type method directly and never looks at the members, so the class declaration cannot break it. Plain obj.rawget(key) is fine for an instance of a class you wrote yourself.
See the .$ operator and types.Table.
Functions
| clone | clone(): any | Creates a new instance of the same class, copying this instance's own field values into it. |
| getclass | pure instance.getclass(): any | Returns the class this instance was constructed from. |
| getfuncinfos | instance.getfuncinfos(): any | Describes this instance's class's _call metamethod, the same way function.getfuncinfos describes a plain function. |
| getmetamethod | instance.getmetamethod(name: string): any | Looks up one of this instance's class's metamethods by name, without triggering it. |
| hasindex | pure instance.hasindex(key): any | Tests whether key names a field or method reachable on this instance. |
| is_frozen | is_frozen(): any | Reports whether this reference to the instance was frozen with freeze(). |
| rawget | pure instance.rawget(key): any | Reads the value stored at key on this instance, without consulting a _get metamethod. |
| rawin | pure instance.rawin(key): any | Tests whether key names a field or method reachable on this instance. |
| rawset | instance.rawset(key, value): any | Replaces the value stored at an existing field of this instance, without consulting a _newslot metamethod. |
| swap | instance.swap(key1, key2): any | Swaps the values stored at two of this instance's fields. |
| tostring | tostring(): any | Converts the instance to a string. |
| weakref | weakref(): any | Returns a weak reference to the instance. |