Ruby | Rational inspect() function
Last Updated :
19 Mar, 2024
The inspect() is an inbuilt function in Ruby returns the value as a string.
Syntax: rat.inspect()
Parameters: The function accepts no parameter
Return Value: It returns the value as a string
Example 1:
rat1 = Rational( 8 , - 6 )
puts rat1.inspect()
|
Output:
(-4/3)
Example 2:
rat1 = Rational( '1/2' )
puts rat1.inspect()
|
Output:
(1/2)
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...