I have an array, let's say it's
array = ["apple", "orange", "banana"]
Also I have a loop:
boxes.each_with_index do |fruit, i|
... some code ...
array[i]
end
I don't know how many boxes are. What I want to achieve is iterating through the array (from "apple" to "orange") as many times as it takes: apple, orange, banana, apple... and again.
I couldn't find a method that can help me to do this. Also, I thought about resetting a counter inside the loop but haven't succeeded as well.
What do you think would be the most elegant solution? Thanks.