# set

Learn how to set a value at a given path.

This method chains a `set` operation to the patch.

The operation creates a new value at the specified path, overwriting any existing value.

> **Atomicity**
>
> If the parent path does not exist, or is not a collection, the operation fails and the entire patch is discarded.

## Signature

This method has the following signature:

```ts
patch.set(path: string, value: JsonValue): Patch
```

The return is the `Patch` instance itself to allow operation chaining.

## Example

Here is a basic example of how to use this method:

```ts
path.set('address.city', 'New York');
```

## Parameters

The following list describes the supported parameters:

- `path`: `string`

  The path to the value to set in dot notation, like `address.city`.

- `value`: `JSON`

  The value to set at the specified path, like `New York`.
