Ruby/Range/include

Материал из Wiki.crossplatform.ru

Перейти к: навигация, поиск

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.