Mega Code Archive

 
Categories / Ruby / Range
 

Each and each_with_index loop with range

(5..7).each {|x| print x }                 # Prints "567" (5..7).each_with_index {|x,i| print x,i }  # Prints "506172"