On May 31, 2006, at 20:35, Wes Gamble wrote: > If I do > > Array.each do | arr_element | > ... > done > > am I guaranteed to get the array elements in order from lowest to > highest? > > Or should I use a for loop to get the array elements? I don't know if it's guaranteed (in the sense that it will never change), but that is what it seems to do: /* * call-seq: * array.each {|item| block } -> array * * Calls <i>block</i> once for each element in <i>self</i>, passing that * element as a parameter. * * a = [ "a", "b", "c" ] * a.each {|x| print x, " -- " } * * produces: * * a -- b -- c -- */ VALUE rb_ary_each(ary) VALUE ary; { long i; for (i=0; i<RARRAY(ary)->len; i++) { rb_yield(RARRAY(ary)->ptr[i]); } return ary; }