Loop through each_index : each_index « Array « Ruby






Loop through each_index


a = ['a','b','c']
a.each_index {|i| print i}         # Array-specific: prints "012"

 

Related examples in the same category