What's the 'Ruby way' to iterate over an array - from array[n] to array[n - 1]?

Say I have an array of size 5. I want to take an index (from 0-4) as input, and iterate through the array, starting at the supplied index.

For example, if the index given was 3, I want to iterate like so:

arr[3]
arr[4]
arr[0]
arr[1]
arr[2]

I can think of plenty of ways to do this - but what's the Ruby way to do it?

6
задан nfm 8 September 2010 в 22:52
поделиться