Skip to content

Commit

Permalink
Add docs for objects
Browse files Browse the repository at this point in the history
  • Loading branch information
James-Livesey committed Jul 1, 2024
1 parent e885f01 commit 6d57843
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions docs/en/voxel/objects.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Objects
The **object** data type is for storing pairs of values. Object entries each consist of a key and their value, and both can be of any type. When something is used as a key, it will be locked and become immutable.

Classes and class intances are also objects.

Objects can be created in Voxel using the following syntax:

```voxel
var item = "banana";
var object = {
"stringKey": 123,
propertyKey: 456,
789: true,
data: null,
message: "hello",
fruit: item,
list: [3, 2, 1],
nested: {object: true}
};
```

## Reference

### `Object`
The object data type.

#### `length: Number`
The number of key-value pair entries in the object.

#### `prototypes: List<Object>`
A mutable list of prototypes that the object inherits. When a key is accessed on the object and the object does not have an entry with the same key, each inherited object in the object's prototypes list will be looked up to find the key, starting from the last prototype in the list.

0 comments on commit 6d57843

Please sign in to comment.