Ruby/Range/include

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

(Различия между версиями)
Перейти к: навигация, поиск

Версия 17:10, 26 мая 2010

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.