Open In App

Ruby | Numeric real? function

Last Updated : 19 Mar, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report
The real?() is an inbuilt method in Ruby returns a boolean value. It returns true if the number is a negative one, else it returns false.
Syntax: num.real?() Parameters: The function needs a number which is to be checked for. Return Value: It returns returns a boolean value.
Example 1: CPP
# Ruby program for real?()
# method in Numeric

# Initialize a number 
num1 = 10

# Prints real or not 
puts num1.real?()
Output:
true
Example 2: CPP
# Ruby program for real?()
# method in Numeric

# Initialize a number 
num1 = Complex(12, 3)

# Prints real or not 
puts num1.real?()
Output:
false

Next Article

Similar Reads