diff options
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 21 |
1 files changed, 20 insertions, 1 deletions
@@ -27,7 +27,7 @@ Mana is a toy programming language written in Go. It is a dynamically typed, int | `BuiltInFunctions` | ✔️ | Built-in Functions are functions that are built into the language | `len("Hello, World!")` | ✔️ | | `ArrayLiteralExpression` | ✔️ | Array Literal Expressions are used to represent array values | `[1, 2, 3]` | ✔️ | | `IndexExpression` | ✔️ | Index Expressions are used to index into arrays | `myArray[0]` | ✔️ | -| `HashLiteralExpression` | NYI | Hash Literal Expressions are used to represent hash values | `{"key": "value"}` | NYI | +| `HashLiteralExpression` | ✔️ | Hash Literal Expressions are used to represent hash values | `{"key": "value"}` | ✔️ | \*_NYI = Not Yet Implemented_ @@ -178,6 +178,25 @@ let u = ["one", "two", 3][5 - 4]; // u = "two" let k = mixed[c - 67]; // k = true ``` +## Hashes + +Hashes in Mana are unordered collections of key-value pairs. Hashes are created using curly braces. Hashes can contain keys of `supported types` (**Boolean**, **Integers**, and **Strings** - Objects which implement the `Hashable` interface). Hashes can contain values of any type, including other hashes. Hashes are indexed using square brackets. The index is a key that represents the key of the element in the hash. + +```rust +let person = { + "name": "Alice", + "age": 30, + "isStudent": false, + "address": { + "street": "123 Main St", + "city": "Anytown" + } +}; + +let name = person["name"]; // name = "Alice" +let city = person["address"]["city"]; // city = "Anytown" +``` + ## Building Advanced Functions **Map** |
