Ruby | Rational abs() function Improve Improve Like Article Like Save Share Report The abs() is an inbuilt function in Ruby returns the absolute value of rational. Syntax: rational.abs() Parameters: The function accepts no parameter Return Value: It returns returns the absolute value of rational. Example 1: # Ruby program for abs() method # Initialize rational number rat1 = Rational(-3, 4) # Prints the rational number puts rat1.abs() Output: 3/4 Example 2: # Ruby program for abs() method # Initialize rational number rat1 = Rational(-4) # Prints the rational number puts rat1.abs() Output: 4/1 Last Updated : 19 Mar, 2024 Like Article Save Article Previous Ruby | Rational + method Next Ruby | Numeric remainder() function Share your thoughts in the comments Add Your Comment Please Login to comment...