Ruby if, else and unless statement: The if expressions execute a single statement or a group of statements if a certain condition is met. It can not do anything if the condition is false. For this purpose else is used.
if conditional [then]
[elsif conditional [then]
Ruby if statement multiple conditions with example.
x = 10
if x > 8 then
puts "x is greater than 8"
x is greater than 8
Use of Multiple Conditions
If two things are true at the same time, then this section is for you. Below is an example:
if name == "David" && country == "UK"
If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.