Ruby | Numeric abs2() function
Last Updated :
19 Mar, 2024
The abs2() is an inbuilt method in Ruby returns the square of a number.
Syntax: num.abs2
Parameters: The function needs the number whose square is to be returned.
Return Value: It returns the square of a number.
Example 1:
Ruby
num = - 19
puts num.abs2()
|
Output:
361
Example 2:
Ruby
num = 100
puts num.abs2()
|
Output:
10000
Share your thoughts in the comments
Please Login to comment...