# map.retrieve()

The `map.retrieve()` function retrieves a value from [`$map`](#usdmap) by a [`$method`](#usdmethod) get or pick with a [`$key`](#usdkey).

{% code lineNumbers="true" %}

```scss
// Functions.
@use 'map.get.function' as *;
@use 'map.pick.function' as *;

// The `map.retrieve()` function.
@function retrieve($method, $map, $key, $fallback: null) {
  @return if(
    $method == get,
    get($map, $key, $fallback),
    if($method == pick, pick($map, $key...), $map or $fallback)
  );
}
```

{% endcode %}

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

### Parameters

#### `$method`

The method get(`map.get()`) or pick(`map.pick()`) used to retrieve the value.

#### `$map`

A map to get the value by using [`$method`](#usdmethod) and [`$key`](#usdkey).

#### `$key`

A key to get or pick the value from [`$map`](#usdmap).

#### `$fallback: null`

The fallback value if returned is `null`.

### Return

The return value is a retrieved value from [`$map`](#usdmap) or [`$fallback`](#usdfallback-null).

## Examples

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

// Examples.
$-dictionary-example: (
  general: (word: słowo, (wrapper, wrap): owijka, (technology, technologia): tech, color: c),
  class: (prefix: class-prefix, separator: class-separator, suffix: class-suffix, calendars: (calendar: cal), labels: (label: lab)),
  prefix: spectre,
  border: b,
  color: c,
  separator: '-',
  suffix: end,
  outline: o,
  var: (prefix: var-prefix, suffix: var-suffix)
);

@debug map.retrieve(get, $-dictionary-example, general); // (word: słowo, (wrapper, wrap): owijka, (technology, technologia): tech, color: c)
@debug map.retrieve(pick, $-dictionary-example, ((class, calendars),)); // (calendars: (calendar: cal))
@debug map.retrieve(pick, $-dictionary-example, (general, (class, calendars))); // (general: (word: słowo, (wrapper, wrap): owijka, (technology, technologia): tech, color: c), calendars: (calendar: cal))

// input list
@debug map.retrieve(pick $-dictionary-example ((class, calendars),)...); // (calendars: (calendar: cal))

// null
@debug map.retrieve(get, $-dictionary-example, test); // null
@debug map.retrieve(pick, $-dictionary-example, test); // (test: 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.retrieve.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.
