Ruby/Range/each
Материал из Wiki.crossplatform.ru
(Различия между версиями)
ViGOur (Обсуждение | вклад) м (1 версия: Импорт выборки материалов по Ruby) |
Текущая версия на 17:59, 13 сентября 2010
A sub range
(1..10).each {|x| print x if x==3..x==5 }
Prints "34". Flips when x == 3 and flops when x==4
(1..10).each {|x| print x if x==3...x>=3 } # Prints "34"
Prints "3". Flips and flops back when x==3
(1..10).each {|x| print x if x==3..x>=3 }