# Immutability

Following the [nested types example](/quickstart/nested_types_example.md):

```javascript
const person2 = person1.set('givenName', 'Javi')

// person2 is a clone of person1 with the givenName
// set to 'Javi', but person1 is not mutated
person2.fullName() // => 'Javi Cejudo'
person1.fullName() // => 'Javier Cejudo'

const person3 = person1.setIn(['pets', 0, 'name'], 'Bane')

person3.pets().get(0).name() // => 'Bane'
person1.pets().get(0).name() // => 'Robbie'
```

The same principle applies across all Modélico classes. In the case of `M.List`, the inner array is frozen. At the time of writing, there is no canonical way of freezing the other inner structures, so a copy is returned each time `.inner()` is called.

```javascript
person1.pets().inner().shift().speak()
// => TypeError: Cannot add/remove sealed array elements
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://modelico.javiercejudo.com/quickstart/immutability.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
