Control Structures – unless Statement in Ruby

Control Structures – unless Statement in Ruby

Control Structure statement is the statement that controls the working flow of any program depending on its condition.


Today in this article we will discuss one of the Basic Control Statement of Ruby i.e. unless

unless Statements

The unless expression is the opposite of an if expression. It executes the line of codes when a conditional is false.

You can use an else block with the unless, just like you did with the if expression. The end keyword is also required to close the block.
For example:

The unless modifiers can also be used to execute code.
For example:

Leave a Reply