Ruby/Range/include

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

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

Текущая версия на 17:59, 13 сентября 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.