each_slice loop with range : As Iterator « Range « Ruby






each_slice loop with range



(1..10).each_slice(4) {|x| print x } # Prints "[1,2,3,4][5,6,7,8][9,10]"

 

Related examples in the same category

1.When a range is used as an iterator, each value in the sequence is returned.
2.each and each_with_index loop with range
3.each_cons loop with range