2023-10-02 01:41:38 +00:00
|
|
|
# Maps
|
|
|
|
|
|
|
|
Also known as Associative Arrays
|
|
|
|
|
|
|
|
|
|
|
|
## Usage without a declaration
|
|
|
|
|
|
|
|
```thp
|
2024-02-20 10:17:21 +00:00
|
|
|
val mut person = Obj {
|
2023-10-02 01:41:38 +00:00
|
|
|
name: "John",
|
|
|
|
surname: "Doe",
|
|
|
|
age: 33,
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
print("Hello {person.name}")
|
|
|
|
|
|
|
|
person.age += 1
|
|
|
|
|
|
|
|
print("You just turned {person.age}")
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
## Usage with a declaration
|
|
|
|
|
|
|
|
```thp
|
|
|
|
obj Person = {
|
|
|
|
String name,
|
|
|
|
String surname,
|
|
|
|
Int age,
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-02-20 10:17:21 +00:00
|
|
|
val john_doe = Person {
|
2023-10-02 01:41:38 +00:00
|
|
|
name: "John",
|
|
|
|
surname: "Doe",
|
|
|
|
age: 33,
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|