# Dart Control flow: Dart Conditional Expression: Ternary Operators

In Dart, conditional expressions using ternary operators provide a concise way to express conditional logic within a single line of code. The syntax of the ternary operator is:

```dart
condition ? expression1 : expression2
```

If the condition evaluates to true, `expression1` is executed; otherwise, `expression2` is executed.

Here's a basic example:

```dart
var x = 10;
var result = (x > 5) ? 'Greater than 5' : 'Less than or equal to 5';
print(result);
```

In this example, if `x` is greater than 5, the string `'Greater than 5'` will be assigned to `result`; otherwise, `'Less than or equal to 5'` will be assigned.

You can also use nested ternary operators for more complex conditions, although it might reduce readability:

```dart
var num = 10;
var result = (num > 0) ? 'Positive' : (num < 0) ? 'Negative' : 'Zero';
print(result);
```

In this case:

* If `num` is greater than 0, `'Positive'` is assigned to `result`.
    
* If `num` is less than 0, `'Negative'` is assigned to `result`.
    
* Otherwise, `'Zero'` is assigned to `result`.
    

While ternary operators can be handy for simple conditional expressions, overuse or excessive nesting can reduce code readability. Use them judiciously to keep your code clean and understandable.
