Radek Radek - 1 year ago 106
Ruby Question

How to iterate through an array starting from the last element? (Ruby)

I came with below solution but I believe that must be nicer one out there ...

array = [ 'first','middle','last']

index = array.length
array.length.times { index -= 1; puts array[index]}

Answer Source
array.reverse.each { |x| puts x }
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download