# no-unused-map-result

Disallow unused Array.map and Iterator.map results

Discarding an Array map wastes its allocated result, while discarding an Iterator map leaves its lazy callback unconsumed.
Instead, you SHOULD call `forEach` when the callback work is intended or remove the unused map operation.

- Category: suspicious
- Level: warning
- Fix: suggestion
- Scope: module

## Reported

```ds title="main.ds"
function append(values: int32[], output: int32[]): void {
    values.map((value) => output.push(value));
}
```

## Accepted

```ds title="main.ds"
function append(values: int32[], output: int32[]): void {
    values.forEach((value) => output.push(value));
}
```

## Prior art

- [eslint-plugin-sonarjs · no-ignored-return](https://github.com/SonarSource/SonarJS/search?q=no-ignored-return&type=code)

[language/linter/src/rules/suspicious/no_unused_map_result.rs:8](https://github.com/destack-sh/destack/blob/main/language/linter/src/rules/suspicious/no_unused_map_result.rs#L8)
