Ruby | Numeric real() function
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:
# Ruby program for real()# method in Numeric # Initialize a number num = Complex(10, 6) # Prints the real partputs num.real() |
Output:
10
Example 2:
# Ruby program for real()# method in Numeric # Initialize a number num = Complex(18, 16) # Prints the real partputs num.real() |
Output:
18


