Skip to content

4.12 Conditional Expressions

  • if x is 2, then the conditional expression 5 if x==2 else 9*x evaluates to 5.
  • Good practice is to restrict usage of conditional expressions to an assignment statement:
    • y = 5 if (x == 2) else 9*x