Ruby | Integer <=> function Last Updated : 12 Jul, 2025 Comments Improve Suggest changes Like Article Like Report The <=> is an inbuilt method in Ruby returns three values -1, 0 or +1. It returns -1 if the number is less than the given number, 0 if both are same, 1 if it is greater than the given number. Syntax: num1 <=> num2 Parameters: The function accepts no parameter. Return Value: It returns -1, 0, +1 as stated above. Example 1: Ruby # Ruby program for <=> method in Integer # Initialize numbers num1 = 6 num2 = 3 # Prints <=> print num1 <=> num2 Output: 1 Example 2: Ruby # Ruby program for <=> method in Integer # Initialize numbers num1 = 2 num2 = 3 # Prints <=> print num1 <=> num2 Output: -1 Example 3: Ruby # Ruby program for <=> method in Integer # Initialize numbers num1 = 3 num2 = 3 # Prints <=> print num1 <=> num2 Output: 0 Comment More infoAdvertise with us Next Article Ruby | Integer >= function G gopaldave Follow Improve Article Tags : Ruby Ruby-Methods Ruby Integer-class Similar Reads Ruby | Integer >= function The >= is an inbuilt method in Ruby returns true if the number is greater than or equal to the given number, else it returns false. Syntax: num1 >= num2 Parameters: The function accepts no parameter. Return Value: It returns true if the number is greater than or equal to the given number, else 1 min read Ruby | Integer >= function The >= is an inbuilt method in Ruby returns true if the number is greater than or equal to the given number, else it returns false. Syntax: num1 >= num2 Parameters: The function accepts no parameter. Return Value: It returns true if the number is greater than or equal to the given number, else 1 min read Ruby | Integer >= function The >= is an inbuilt method in Ruby returns true if the number is greater than or equal to the given number, else it returns false. Syntax: num1 >= num2 Parameters: The function accepts no parameter. Return Value: It returns true if the number is greater than or equal to the given number, else 1 min read Ruby | Integer << function The << is an inbuilt method in Ruby returns the number which is shifted N times to the left. The resultant number is num * (2^N). Syntax: num << N Parameters: The function accepts no parameter. Return Value: It returns num * (2^N). Example 1: Ruby # Ruby program for << method in In 1 min read Ruby | Integer << function The << is an inbuilt method in Ruby returns the number which is shifted N times to the left. The resultant number is num * (2^N). Syntax: num << N Parameters: The function accepts no parameter. Return Value: It returns num * (2^N). Example 1: Ruby # Ruby program for << method in In 1 min read Ruby | Integer << function The << is an inbuilt method in Ruby returns the number which is shifted N times to the left. The resultant number is num * (2^N). Syntax: num << N Parameters: The function accepts no parameter. Return Value: It returns num * (2^N). Example 1: Ruby # Ruby program for << method in In 1 min read Like