Ruby | Numeric method
Last Updated :
19 Mar, 2024
The <=> is an inbuilt method in Ruby, which returns 0 if both the numbers are equal, else it returns 1.
Syntax: a <=> b
Parameters: The function needs two number whose comparison is to be done.
Return Value: It returns 0 if both the numbers are same, else it returns 1.
Example 1:
Output:
1
Example 2:
Ruby
a = 13
b = 13
puts a <=> b
|
Output:
0
Share your thoughts in the comments
Please Login to comment...