OneBite.Dev - Coding blog in a bite size

use a conditional to check less than number in Ruby

Code snippet on how to use a conditional to check less than number in Ruby

  num1 = 5; 
  num2 = 10; 
       
  # checking if num1 is less than num2 
  if (num1 < num2) 
    puts "num1 is less than num2"
  end 

This code uses a conditional to check if one number is less than another. First, two variables, “num1” and “num2” are declared and assigned two different numbers. Then, the conditional statement checks whether num1 is less than num2, by using the “less than” operator “<”. If this statement is true, the statement within the if block is printed: “num1 is less than num2”. Finally, the condition is ended with the “end” keyword.

ruby