Mega Code Archive

 
Categories / Ruby / Language Basics
 

The == and eql return true or false

# the <=> (spaceship operator) returns -1, 0, or 1,  # depending on whether the first value is equal to the second (0),  # less than the second (-1), or greater than the second (1). # Test if two numbers are equal, less than, or greater than each other puts 12 < 14 #less than puts 12 < 12 puts 12 <= 12 # less than or equal to puts 12.0 > 11.9 puts 12.0 >= 12 # greater than or equal to