What is the float.quo() method in Ruby?

Overview

The quo() method in Ruby can be used to get the quotient of two numbers. It is invoked by a float value. The parameter that it takes is the divisor.

Syntax

flt.quo(no)

Parameters

no: This is the divisor or the value with which the float value flt is divided. It is a mandatory parameter.

Return value

This method returns the quotient obtained from dividing flt by no.

Code example

# create some float values
float_one = 3.145
float_two = 100.7
float_three = -2.5
# use the quo() method and printed results
puts float_one.quo(1)
puts float_two.quo(5)
puts float_three.quo(-2.5)

Explanation

  • Lines 2-4: We create three float values.
  • Lines 7-9: We call the quo() method on the float values and print the results to the console.