Add oop.rhai script.

This commit is contained in:
Stephen Chung
2020-06-27 17:34:39 +08:00
parent d509006264
commit 549ef6bf7f
7 changed files with 62 additions and 3 deletions

View File

@@ -3,7 +3,7 @@ Special Support for OOP via Object Maps
{{#include ../links.md}}
[Object maps] can be used to simulate object-oriented programming ([OOP]) by storing data
[Object maps] can be used to simulate [object-oriented programming (OOP)][OOP] by storing data
as properties and methods as properties holding [function pointers].
If an [object map]'s property holds a [function pointer], the property can simply be called like

View File

@@ -50,6 +50,7 @@ operate on object maps:
| `remove` | property name | removes a certain property and returns it ([`()`] if the property does not exist) |
| `+=` operator, `mixin` | second object map | mixes in all the properties of the second object map to the first (values of properties with the same names replace the existing values) |
| `+` operator | first object map, second object map | merges the first object map with the second |
| `fill_with` | second object map | adds in all properties of the second object map that do not exist in the object map |
| `keys` | _none_ | returns an [array] of all the property names (in random order), not available under [`no_index`] |
| `values` | _none_ | returns an [array] of all the property values (in random order), not available under [`no_index`] |