Is the .each iterator in ruby guaranteed to give the same order on the same elements every time?

后端 未结 4 626
臣服心动
臣服心动 2020-12-19 04:52

I\'m doing something like this with a list \'a\':

a.each_with_index |outer, i|
  a.each_with_index |inner, j|
    if(j > i)
      # do some operation with         


        
4条回答
  •  盖世英雄少女心
    2020-12-19 05:28

    I've not looked at your actual code but here is your answer taken from the Ruby API docs:

    Arrays are ordered, integer-indexed collections of any object.

    So yes, you are being paranoid but surely that's a good thing when you're developing?

提交回复
热议问题