# map.set()

The `map.set()` function sets [`$allowed`](#usdallowed...) [`$value`](#usdvalue) under [`$key`](#usdkey).

{% hint style="info" %}
Original sass `map.set()` function modified, by adding [`$allowed...`](https://docs.angular-package.dev/sass/map/pages/eA1D2RSFMwcOSbBuLIN8#usdallowed...) arbitrary argument to check if [`$value`](#usdvalue) is allowed to be set.
{% endhint %}

{% code lineNumbers="true" %}

```scss
// Sass.
@use 'sass:list';
@use 'sass:map';
@use 'sass:meta';

// The `map.set()` function.
@function update($map, $key-value, $allowed...) {
  @each $key, $value in $key-value {
    $map: set($map, $key, $value, $allowed...);
  }
  @return $map;
}
```

{% endcode %}

{% embed url="<https://github.com/angular-package/sass/blob/main/map/_map.set.function.scss>" %}

### Parameters

#### `$map`

A map to set [`$value`](#usdvalue) at [`$key`](#usdkey).

#### `$key`

A key under which [`$value`](#usdvalue) is set.

#### `$value`

The value to set in [`$map`](#usdmap) under [`$key`](#usdkey).

#### `$allowed...`

Allowed value types and/or values to set in [`$map`](#usdmap).

### Return

The return value is updated [`$map`](#usdmap) with [`$value`](#usdvalue) at [`$key`](#usdkey).

## Examples

```scss
// Use.
@use '@angular-package/sass/map';

// Examples.
@debug map.set((), ((test, 1),), 2222); // ((test, 1): 2222)
@debug map.set((), (test 1, (test, 2)), 2222); // (test 1: ((test, 2): 2222))

// single type
@debug map.set((a: 1, b: 2), test string, 27, string ); // (a: 1, b: 2)
@debug map.set((a: 1, b: 2), test number, 27, number); // (a: 1, b: 2, test: (number: 27))
@debug map.set((a: 1, b: 2), test map, (map: 22,), map); // (a: 1, b: 2, test: (map: (map: 22)))
@debug map.set((a: 1, b: 2), test list, (22, 44), list); // (a: 1, b: 2, test: (list: (22, 44)))
@debug map.set((a: 1, b: 2), test color, #ffffff, color); // (a: 1, b: 2, test: (color: #ffffff))
@debug map.set((a: 1, b: 2), test null, null, null); // (a: 1, b: 2, test: (null: null))

// multiple types
@debug map.set((a: 1, b: 2), test number, 27, number, string, bool, list, map); // (a: 1, b: 2, test: (number: 27))
@debug map.set((a: 1, b: 2), test string, twenty seven, number, string, bool, list, map); // (a: 1, b: 2, test: (string: twenty seven))
@debug map.set((a: 1, b: 2), test bool, false, number, string, bool, list, map); // (a: 1, b: 2, test: (bool: false))
@debug map.set((a: 1, b: 2), test null, null, number, null, string, bool, list, map); // (a: 1, b: 2, test: (null: null))

```


---

# 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://docs.angular-package.dev/sass/map/map.set.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.
