作者:博菡 | 来源:互联网 | 2023-06-21 18:17
I have an array in Ruby 2.0:
我在Ruby 2.0中有一个数组:
arr=[1,2,3,4,5]
I would like to be able to do something like:
我希望能够做到这样的事情:
arr[6] #=> 2
That is - roll over the end of the array and restart. Is that possible?
那就是 - 滚动数组的末尾并重新启动。那可能吗?
2 个解决方案