Conditional Statements

The most commonly used conditional statement in Ruby is the if statement. It contains a conditional expression and a true branch, and it may contain a false branch. The true branch is executed when the conditional expression is true. The false branch, if present, is executed when the conditional expression is false. The following program demonstrates the use of the conditional statement.

Get hands-on with 1200+ tech skills courses.