views:

241

answers:

2

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]}
+3  A: 
array.reverse.each { |x| puts x }
ennuikiller
I knew there would be something `nice` ... Thank you.
Radek
Actually, `reverse_each` is better because it doesn't make a copy of the array as `reverse` does.
Mladen Jablanović
+5  A: 

Ruby is smart

a = [ "a", "b", "c" ]
a.reverse_each {|x| print x, " " }
allenwei