# All Values For A Key In A Keyword List

A keyword list in Elixir can contain the same key multiple times.

```elixir
kwl = [a: 1, b: 2, a: 3, c: 4]
#=> [a: 1, b: 2, a: 3, c: 4]
```

The `get/2` function will only grab the value of the first occurrence.

```elixir
Keyword.get(kwl, :a)
#=> 1
```

You can use `get_values/2` to retrieve *all* values associated with the key.

```elixir
Keyword.get_values(kwl, :a)
#=> [1, 3]
```


---

# 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://ploegert.gitbook.io/til/programmy/elixir/all-values-for-a-key-in-a-keyword-list.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.
