Mega Code Archive

 
Categories / Ruby / Range
 

Each_cons loop with range

(1..5).each_cons(3) {|x| print x }    # Prints "[1,2,3][2,3,4][3,4,5]"