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.
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
.
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.
18.117.138.178