ruby comparison operators

Ruby Comparison Operators

The comparison operators in Ruby are used to compare two values. Here are the main comparison operators in Ruby:

  1. Equal: == - This operator returns true if the values on both sides are equal, otherwise it returns false.
  2. Not Equal: != - This operator returns true if the values on both sides are not equal, otherwise it returns false.
  3. Greater Than: > - This operator returns true if the value on the left is greater than the value on the right, otherwise it returns false.
  4. Less Than: < - This operator returns true if the value on the left is less than the value on the right, otherwise it returns false.
  5. Greater Than or Equal To: >= - This operator returns true if the value on the left is greater than or equal to the value on the right, otherwise it returns false.
  6. Less Than or Equal To: <= - This operator returns true if the value on the left is less than or equal to the value on the right, otherwise it returns false.

These operators are commonly used in conditional statements and loops to control the flow of a program.