Ruby | Numeric phase() function
The phase() is an inbuilt method in Ruby returns 0 if the value is positive, else it returns a float value pi.
Syntax: num.phase()
Parameters: The function needs a number which is to be checked.
Return Value: It returns zero if the value is positive, else it returns a float value pi.
Example 1:
num1 = 10
puts num1.phase()
|
Output:
0
Example 2:
num1 = - 10
puts num1.phase()
|
Output:
3.141592653589793
Last Updated :
19 Mar, 2024
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...