Related Articles

Related Articles

Ruby | Numeric positive? function
  • Last Updated : 06 Jan, 2020

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

Syntax: num.positive?()

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

Return Value: It returns returns a boolean value.

Example 1:



filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output:

true

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output:

false
My Personal Notes arrow_drop_up
Recommended Articles
Page :