Skip to content

Files

Latest commit

 

History

History
26 lines (18 loc) · 729 Bytes

Style-NestedTernaryOperator.md

File metadata and controls

26 lines (18 loc) · 729 Bytes

Pattern: Nested ternary operator

Issue: -

Description

Use one expression per branch in a ternary operator. This also means that ternary operators must not be nested. Prefer if/else constructs in these cases.

Examples

# bad
some_condition ? (nested_condition ? nested_something : nested_something_else) : something_else

# good
if some_condition
  nested_condition ? nested_something : nested_something_else
else
  something_else
end

Further Reading