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]}
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]}
In case you want to iterate through a range in reverse then use:
If you want to achieve the same without using reverse [Sometimes this question comes in interviews]. We need to use basic logic.
output to screen or a new array or use the loop to perform any logic.
Ruby is smart
In a jade template you can use:
You can even use a for loop
will print