# no-nested-ternary

Disallow nested ternary expressions

A ternary nested directly inside another ternary forces multiple conditions and results into a grouping determined by operator associativity.
Instead, you SHOULD use explicit control flow for each condition and result.

- Category: style
- Level: warning
- Fix: none
- Scope: module

## Reported

```ds title="main.ds"
function classify(value: int32): string {
    return value > 0 ? "positive" : value < 0 ? "negative" : "zero";
}
```

## Accepted

```ds title="main.ds"
function classify(value: int32): string {
    if (value > 0) {
        return "positive";
    }
    if (value < 0) {
        return "negative";
    }
    return "zero";
}
```

## Prior art

- [ESLint · no-nested-ternary](https://eslint.org/docs/latest/rules/no-nested-ternary)

[language/linter/src/rules/style/no_nested_ternary.rs:6](https://github.com/destack-sh/destack/blob/main/language/linter/src/rules/style/no_nested_ternary.rs#L6)
