Ruby/Range/each

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

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

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 }