4.7 Summary

We discussed how to implement conditional execution in Ruby. The if statement can cover simple conditions, and the case statement can cover more complex conditions. Relational operators, outlined in Table 4-1, were introduced, as well as their combinations and negations.

4.7.1 Key Concepts

  • Every program follows a control flow, which is dictated by the logic flow of its algorithms. Logic flow and control flow can be better understood in a flowchart, and are often one-directional or conditional.

  • Relational operators are the key to creating conditional flow. An expression that uses a relational operator is known as a relational expression.

  • Another way to create conditional flow is through the use of advanced conditional structures. This is done by employing special statements, such as if, elsif, and case.

4.7.2 Key Definitions

  • Flowchart: A tool for understanding the logic flow of an algorithm or the control flow of a program.

  • Logic flow: The order in which an algorithm performs key steps:

    • One-directional flow: When the logic flow of an algorithm follows a one-directional order (i.e., a straight line)

    • Conditional flow: When the logic flow of an algorithm follows a conditional order (i.e., different conditions lead to different paths)

  • Relational expression: An expression that uses a relational operator.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.138.178