Details
-
Improvement
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
None
-
None
-
None
Description
"Else if" (elif) statements are useful since they avoid the need for nested if/else statements. Currently, DML has "else if" but PyDML does not have an equivalent "elif".
As an example, here is DML containing "else if" statements:
x = 6 if (x == 1) { print('A') } else if (x == 2) { print('B') } else if (x == 3) { print('C') } else if (x == 4) { print('D') } else if (x == 5) { print('E') } else { print('F') }
Here is the logical equivalent in PyDML using nested "if else" statements:
x = 6 if (x == 1): print('A') else: if (x == 2): print('B') else: if (x == 3): print('C') else: if (x == 4): print('D') else: if (x == 5): print('E') else: print('F')
The nesting becomes especially challenging in a Python-like language as the number of nested "if else" statements increases due to the use of whitespace indentations to specify blocks of code.