The include Function can be used to check whether a particular number is within a range or not. : include « Range « Ruby






The include Function can be used to check whether a particular number is within a range or not.


# The include function always will return a true or false. 

range1 = 1..100

puts range1.include? (6)

# This code returns true because range1 contains numbers from 1 to 100.

 








Related examples in the same category