What is num.abs() in Ruby?
The abs() function returns the absolute value of a number.
Figure 1 shows a mathematical representation of the abs() function.
Syntax
num.abs()
# where num is the number whose absolute value is required
Parameter
The abs() function does not take any parameter.
Return value
The abs() function returns the absolute value of a number passed in as a parameter.
Code
#positive numberprint "The value of abs(10) : ", (10).abs(), "\n"#zeroprint "The value of abs(0) : ", (0).abs(), "\n"#negative numberprint "The value of abs(-10) : ", (-10).abs(), "\n"