Ruby | Numeric numerator() function
The numerator() is an inbuilt method in Ruby returns the numerator.
Syntax: num.numerator()
Parameters: The function needs a number which is to be checked.
Return Value: It returns self or nil.
Example 1:
# Ruby program for numerator() # method in Numeric # Initialize a number num1 = 3 . 5 # Prints the numerator puts num1.numerator() |
Output:
12
Example 2:
# Ruby program for numerator() # method in Numeric # Initialize a number num1 = 1 . 5 # Prints the numerator puts num1.numerator() |
Output:
3