Skip to content

Latest commit

 

History

History
44 lines (31 loc) · 770 Bytes

NestedTernaryOperator.md

File metadata and controls

44 lines (31 loc) · 770 Bytes

Nested ternary operator (NestedTernaryOperator)

Description

Use of nested ternary operators decrease code readability.

Examples

Incorrect use of ternary operators

Result = ?(X%15 <> 0, ?(X%5 <> 0, ?(X%3 <> 0, x, "Fizz"), "Buzz"), "FizzBuzz"); 
If ?(P.Emp_emptype = Null, 0, PageEmp_emptype) = 0 Then

      Status = "Done";

EndIf;

Possible implementation

If x % 15 = 0 Then
    Result = "FizzBuzz";
ElseIf x % 3 = 0 Then
    Result = "Fizz";
ElseIf x % 5 = 0 Then
    Result = "Buzz";
Else
    Result = x;
EndIf;
If PageEmp_emptype = Null OR PageEmp_emptype = 0 Then

      Status = "Done";

End If;