Skip to content
Related Articles

Related Articles

Ruby | Numeric integer() function
  • Last Updated : 06 Jan, 2020

The integer?() is an inbuilt method in Ruby returns a boolean value. It returns true if the number is an integer one, else it returns false.

Syntax: num.integer?()

Parameters: The function needs a number which is to be checked for.

Return Value: It returns returns a boolean value.

Example 1:






# Ruby program for integer?()
# method in Numeric
  
# Initialize a number 
num1 = 15
  
# Prints integer or not 
puts num1.integer?()


Output:

true

Example 2:




# Ruby program for integer?()
# method in Numeric
  
# Initialize a number 
num1 = 15.6
  
# Prints integer or not 
puts num1.integer?()


Output:

false
My Personal Notes arrow_drop_up
Recommended Articles
Page :