Skip to content
Related Articles

Related Articles

Improve Article

Ruby | Numeric arg() function

  • Last Updated : 19 Jan, 2021

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

 

My Personal Notes arrow_drop_up
Recommended Articles
Page :