Ruby | Numeric real() function
Last Updated :
19 Mar, 2024
The real() is an inbuilt method in Ruby returns the real part of the given number.
Syntax: num.real()
Parameters: The function needs the number whose real part is to be returned.
Return Value: It returns the real part of the complex number.
Example 1:
num = Complex( 10 , 6 )
puts num.real()
|
Output:
10
Example 2:
num = Complex( 18 , 16 )
puts num.real()
|
Output:
18
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...