Skip to content
Related Articles

Related Articles

Ruby | Numeric numerator() function
  • Last Updated : 06 Jan, 2020

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:



filter_none

edit
close

play_arrow

link
brightness_4
code

# Ruby program for numerator()
# method in Numeric
  
# Initialize a number 
num1 = 3.5
  
# Prints the numerator
puts num1.numerator()

chevron_right


Output:

12

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

# Ruby program for numerator()
# method in Numeric
  
# Initialize a number 
num1 = 1.5
  
# Prints the numerator
puts num1.numerator()

chevron_right


Output:

3
My Personal Notes arrow_drop_up
Recommended Articles
Page :