Open In App
Related Articles

Ruby | Rational numerator() function

Improve Article
Improve
Save Article
Save
Like Article
Like

The numerator() is an inbuilt function in Ruby returns the numerator.

Syntax: rat.numerator()

Parameters: The function accepts no parameter

Return Value: It returns the numerator

Example 1:




# Ruby program for numerator() method
  
# Initialize rational number
rat1 = Rational(7, -3)
  
# Prints the rational number
puts rat1.numeratorr()


Output:

-7

Example 2:




# Ruby program for numerator() method
  
# Initialize rational number
rat1 = Rational(7)
  
# Prints the rational number
puts rat1.numerator()


Output:

7
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 06 Jan, 2020
Like Article
Save Article
Previous
Next
Similar Reads