Ruby | Numeric arg() function
The arg() is an inbuilt method in Ruby returns 0 if the number is positive, else it returns a float value which is equal to pi.
Syntax: num.arg()
Parameters: The function needs a number.
Return Value: It returns 0 if the number is positive, else it returns a float value which is equal to pi. .
Example 1:
Ruby
# Ruby program for arg() method in Numeric # Initialize a number num = - 19 # Prints arg() of num puts num.arg() |
Output:
3.141592653589793
Example 2:
Ruby
# Ruby program for arg() method in Numeric # Initialize a number num = 100 # Prints arg() of num puts num.arg() |
Output:
0